Permalink
Browse files

Remove uneeded second calculation of md5sum of generated archive.

Pass the calculated md5sum as 2nd argument to purge_duplicate_archives
to save (a significant for large archives) execution time.
  • Loading branch information...
1 parent d23ed2d commit 271f93da42ebd8e09209f3550ba624b9e37a9a57 Georgios M. Zarkadas committed Feb 10, 2012
Showing with 11 additions and 4 deletions.
  1. +3 −2 lib/backup-methods.sh
  2. +8 −2 lib/files.sh
View
@@ -47,8 +47,9 @@ function commit_archive()
echo "$md5hash $base" >> $MD5FILE
fi
- # Now that the file is created, remove previous duplicates if exists...
- purge_duplicate_archives $file_to_create ||
+ # Now that the file is created, remove previous duplicates if exist.
+ # Pass in the calculated (costly) md5 sum, to speed things up.
+ purge_duplicate_archives $file_to_create $md5hash ||
error "Unable to purge duplicates of \$file_to_create"
# ownership
View
@@ -380,9 +380,15 @@ function clean_directory()
function purge_duplicate_archives()
{
file_to_create="$1"
- debug "purge_duplicate_archives ($file_to_create)"
- md5hash=$(get_md5sum $file_to_create)
+ if [[ -z "$2" ]]; then
+ debug "purge_duplicate_archives ($file_to_create)"
+ md5hash=$(get_md5sum $file_to_create)
+ else
+ # if the 2nd argument exists, it is the md5sum
+ md5hash="$2"
+ debug "purge_duplicate_archives ($file_to_create, $md5hash)"
+ fi
# Only purge if BM_ARCHIVE_PURGEDUPS = true
if [[ -z "$BM_ARCHIVE_PURGEDUPS" ]] ||

0 comments on commit 271f93d

Please sign in to comment.