mirror of https://github.com/CIRCL/PyCIRCLean
Proper handling of symlinks
parent
66dc401727
commit
936fc2c2a2
|
@ -213,6 +213,9 @@ class KittenGroomerFileCheck(KittenGroomerBase):
|
||||||
# ##### Discarded mime types, reason in the comments ######
|
# ##### Discarded mime types, reason in the comments ######
|
||||||
def inode(self):
|
def inode(self):
|
||||||
''' Usually empty file. No reason (?) to copy it on the dest key'''
|
''' Usually empty file. No reason (?) to copy it on the dest key'''
|
||||||
|
if self.cur_file.is_symlink():
|
||||||
|
self.cur_file.log_string += 'Symlink to {}'.format(self.log_details['symlink'])
|
||||||
|
else:
|
||||||
self.cur_file.log_string += 'Inode file'
|
self.cur_file.log_string += 'Inode file'
|
||||||
|
|
||||||
def unknown(self):
|
def unknown(self):
|
||||||
|
|
|
@ -66,6 +66,12 @@ class FileBase(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_symlink(self):
|
||||||
|
if self.has_mimetype() and self.main_type == 'inode' and self.sub_type == 'symlink':
|
||||||
|
self.log_details.update({'symlink': os.readlink(self.src_path)})
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def add_log_details(self, key, value):
|
def add_log_details(self, key, value):
|
||||||
'''
|
'''
|
||||||
Add an entry in the log dictionary
|
Add an entry in the log dictionary
|
||||||
|
@ -165,9 +171,11 @@ class KittenGroomerBase(object):
|
||||||
files = sorted(os.listdir(base_dir))
|
files = sorted(os.listdir(base_dir))
|
||||||
for f in files:
|
for f in files:
|
||||||
curpath = os.path.join(base_dir, f)
|
curpath = os.path.join(base_dir, f)
|
||||||
if os.path.isdir(curpath):
|
if os.path.islink(curpath):
|
||||||
|
lf.write('{}+-- {}\t- Symbolic link to {}\n'.format(padding, f, os.readlink(curpath)))
|
||||||
|
elif os.path.isdir(curpath):
|
||||||
self.tree(curpath, padding)
|
self.tree(curpath, padding)
|
||||||
else:
|
elif os.path.isfile(curpath):
|
||||||
lf.write('{}+-- {}\t- {}\n'.format(padding, f, self._computehash(curpath)))
|
lf.write('{}+-- {}\t- {}\n'.format(padding, f, self._computehash(curpath)))
|
||||||
|
|
||||||
# ##### Helpers #####
|
# ##### Helpers #####
|
||||||
|
|
Loading…
Reference in New Issue