From 4a31fcfb6884fc18a85f390ab6707468f05eebd9 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Thu, 13 Jul 2017 15:00:27 -0400 Subject: [PATCH] Set file sizes to -1 before creating the file reader --- integration_tests/resume_test.sh | 3 ++- integration_tests/test.sh | 1 + src/duplicacy_backupmanager.go | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/integration_tests/resume_test.sh b/integration_tests/resume_test.sh index 4989300..5507bfc 100755 --- a/integration_tests/resume_test.sh +++ b/integration_tests/resume_test.sh @@ -11,8 +11,9 @@ ${DUPLICACY} init integration-tests $TEST_STORAGE -c 4 # Create 10 small files add_file file1 20 add_file file2 20 -add_file file3 20 +rm file3; touch file3 add_file file4 20 +chmod u-r file4 add_file file5 20 add_file file6 20 add_file file7 20 diff --git a/integration_tests/test.sh b/integration_tests/test.sh index 0066b2b..404c932 100755 --- a/integration_tests/test.sh +++ b/integration_tests/test.sh @@ -10,6 +10,7 @@ backup add_file file3 backup add_file file4 +chmod u-r ${TEST_REPO}/file4 backup add_file file5 restore diff --git a/src/duplicacy_backupmanager.go b/src/duplicacy_backupmanager.go index dc59061..876f2da 100644 --- a/src/duplicacy_backupmanager.go +++ b/src/duplicacy_backupmanager.go @@ -361,14 +361,16 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta var uploadedChunkLengths []int var uploadedChunkLock = &sync.Mutex{} - // the file reader implements the Reader interface. When an EOF is encounter, it opens the next file unless it - // is the last file. - fileReader := CreateFileReader(shadowTop, modifiedEntries) - // Set all file sizes to -1 to indicate they haven't been processed + // Set all file sizes to -1 to indicate they haven't been processed. This must be done before creating the file + // reader because the file reader may skip inaccessible files on construction. for _, entry := range modifiedEntries { entry.Size = -1 } + // the file reader implements the Reader interface. When an EOF is encounter, it opens the next file unless it + // is the last file. + fileReader := CreateFileReader(shadowTop, modifiedEntries) + startUploadingTime := time.Now().Unix() lastUploadingTime := time.Now().Unix()