From a080c887172c91c906e41aeccbde26962ac7c752 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Tue, 9 Apr 2013 11:30:36 +0400 Subject: [PATCH] Fix file magic for kernel 3.7.7 --- pym/cl_utils.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 658b74c..fb5582f 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -121,7 +121,18 @@ class typeFile: def getMType(self, filename): """Информация о типе файла""" - return self.magicObject.file(filename) + ret = self.magicObject.file(filename) + # fix for kernel 3.7.7 (bad work samba with big files) + if ret is None and self.magicObject.errno() == 5: + r,w = os.pipe() + devnull = os.open(os.devnull,os.O_WRONLY) + cat = subprocess.Popen(['/bin/cat',filename],stdout=w, + stderr=devnull,close_fds=True) + ret = self.magicObject.descriptor(r) + os.close(w) + os.close(devnull) + cat.wait() + return ret def isBinary(self, filename): """является ли файл бинарным"""