Bug on 'check' command for directories

The command always showed a directory mismatch, because of filecmp.cmp
function being applied to dirs (and not files only, duh).
master
Lertsenem 2016-02-25 02:33:54 +01:00
parent d963b185c8
commit 73c3629ab6
1 changed files with 12 additions and 8 deletions

View File

@ -136,18 +136,22 @@ def _compare_and_log(original_file_path, persoconf_backup_path, logger):
is_dir = os.path.isdir( resolved_ofp )
if filecmp.cmp(resolved_ofp, resolved_pbp) :
if is_dir:
logger.info( "No modification on %s/"
dcmp = filecmp.dircmp(resolved_ofp, resolved_pbp)
if ( len(dcmp.diff_files) > 0
or len(dcmp.left_only) > 0
or len(dcmp.right_only) > 0 ):
logger.warning( "Dir %s/ was modified"
% original_file_path )
else:
logger.info( "No modification on %s/"
% original_file_path )
else:
if filecmp.cmp(resolved_ofp, resolved_pbp) :
logger.info( "No modification on %s"
% original_file_path )
else:
if is_dir:
logger.warning( "Dir %s/ was modified"
% original_file_path )
else:
logger.warning( "File %s was modified"
% original_file_path )