Skip to content

Commit

Permalink
Fix #40 by decrease log level
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Mar 5, 2020
1 parent f4a87a8 commit d843870
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions pyhardlinkbackup/phlb/deduplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def deduplicate(backup_entry, hash_hexdigest):
assert backup_entry.is_file(), f"Is not a file: {backup_entry.path}"

old_backups = BackupEntry.objects.filter(content_info__hash_hexdigest=hash_hexdigest)
# log.debug("There are %i old backup entries for the hash", old_backups.count())
log.debug("There are %i old backup entries for the hash", old_backups.count())
old_backups = old_backups.exclude(no_link_source=True)
# log.debug("%i old backup entries with 'no_link_source=False'", old_backups.count())
log.debug("%i old backup entries with 'no_link_source=False'", old_backups.count())
for old_backup in old_backups:
log.debug("+++ old: '%s'", old_backup)

Expand Down Expand Up @@ -57,16 +57,16 @@ def deduplicate(backup_entry, hash_hexdigest):
suffix=".tmp",
tmp_max=10,
)
log.debug(f"{backup_entry} was renamed to {temp_filepath}")
log.debug("%s was renamed to %s", backup_entry, temp_filepath)
try:
abs_old_backup_path.link(backup_entry) # call os.link()
except OSError as err:
temp_filepath.rename(backup_entry)
log.error(f"Can't link '{abs_old_backup_path}' to '{backup_entry}': {err}")
log.info("Mark %r with 'no link source'.", old_backup)
log.debug("Mark %r with 'no link source'.", old_backup)
old_backup.no_link_source = True
old_backup.save()
else:
temp_filepath.unlink() # FIXME
log.info(f"Replaced with a hardlink to: '{abs_old_backup_path}'")
log.debug('Replaced with a hardlink to: %s', abs_old_backup_path)
return old_backup
5 changes: 2 additions & 3 deletions pyhardlinkbackup/phlb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def fast_compare(self, dir_path):
if mtime_ns > self.latest_mtime_ns:
# The current source file is newer than
# the latest file from last completed backup
log.info("Fast compare: source file is newer than latest backuped file.")
log.debug("Fast compare: source file is newer than latest backuped file.")
return

# Look into database and compare mtime and size
Expand All @@ -134,8 +134,7 @@ def fast_compare(self, dir_path):

file_size = content_info.file_size
if file_size != dir_path.stat.st_size:
log.info(
f"Fast compare: File size is different: {file_size} != {dir_path.stat.st_size}")
log.debug("Fast compare: File size is different: %s != %s", file_size, dir_path.stat.st_size)
return

old_backup_filepath = old_backup_entry.get_backup_path()
Expand Down

0 comments on commit d843870

Please sign in to comment.