From b954ff7e83f2ef7c503e8249bbc9f10c5e901ade Mon Sep 17 00:00:00 2001 From: Bert Burgemeister Date: Wed, 17 Feb 2010 14:17:20 +0100 Subject: [PATCH] Bug fix. - safe_read wasn't able to use the backup file. - New test added which would have found this bug. --- monikop | 4 ++-- test/test.sh | 32 +++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/monikop b/monikop index 88fb906..284a9b4 100755 --- a/monikop +++ b/monikop @@ -180,8 +180,8 @@ sub safe_read { my ($filename) = @_; my $filename_a = $filename; my $filename_b = $filename . $safe_file_backup_suffix; - if (stat $filename_a) { my $filename = $filename_a } - elsif (stat $filename_b) { my $filename = $filename_b } + if (stat $filename_a) { $filename = $filename_a } + elsif (stat $filename_b) { $filename = $filename_b } else { return () } debug_print "SAFE_READ: $filename"; read_list $filename; diff --git a/test/test.sh b/test/test.sh index b97d9c8..0cd0f99 100755 --- a/test/test.sh +++ b/test/test.sh @@ -158,6 +158,14 @@ function fill_sources_with_hidden_files { done } +function fill_sources_with_few_small_files { + for i in 01 02; do + for j in file_one file_two file_three; do + make_test_file $MNT/$i/data/$j.$i 20 200004250955.10 + done + done +} + function fill_destinations_with_few_small_files { for i in 03 04; do for j in file_one file_two file_three; do @@ -333,9 +341,9 @@ function test_pokinom_older_files_lose { ###################################################################### start_rsyncd -########################## -### Run tests: Monikop -########################## +######################### +## Run tests: Monikop +######################### fill_sources_with_big_files @@ -408,6 +416,24 @@ run_test 0 test_monikop_simple_2 "Connection to source destroyed." rm -rf $MNT/0{3,4,5}/* $LOG +fill_sources_with_few_small_files + +run_test 0 test_monikop_short "Don't re-rsync after deletion of finished.* (Preparation #1)." +rm -rf $MNT/{03,04}/* +run_test 1 test_monikop_short "Don't re-rsync after deletion of finished.* (Preparation #2, fill finished.*)." +rm -f $LOG/log.rsync___localhost_2000_test_* +rm -f $LOG/finished.rsync___localhost_2000_test_*_data +run_test 1 test_monikop_short "Don't re-rsync after deletion of finished.*" +rm -rf $MNT/0{3,4}/* $LOG +run_test 0 test_monikop_short "Don't re-rsync after deletion of finished.*.bak (Preparation #1)." +rm -rf $MNT/{03,04}/* +run_test 1 test_monikop_short "Don't re-rsync after deletion of finished.*.bak (Preparation #2, fill finished.*)." +rm -f $LOG/log.rsync___localhost_2000_test_* +rm -f $LOG/finished.rsync___localhost_2000_test_*_data.bak +run_test 1 test_monikop_short "Don't re-rsync after deletion of finished.*.bak." + +rm -rf $MNT/0{3,4}/* $LOG + ############################## # Run tests: Pokinom ############################## -- 2.11.4.GIT