1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-06 00:03:38 +00:00

Fixed #76: must create a new chunk for uploading in the copy operation

This commit is contained in:
Gilbert Chen
2017-06-15 10:48:24 -04:00
parent 112d5b22e5
commit 28da4d15e2
3 changed files with 27 additions and 3 deletions

View File

@@ -13,5 +13,5 @@ add_file file4
backup backup
add_file file5 add_file file5
restore restore
check

View File

@@ -26,6 +26,9 @@ TEST_REPO=$TEST_ZONE/TEST_REPO
# Storage for test ( For now, only local path storage is supported by test suite) # Storage for test ( For now, only local path storage is supported by test suite)
TEST_STORAGE=$TEST_ZONE/TEST_STORAGE TEST_STORAGE=$TEST_ZONE/TEST_STORAGE
# Extra storage for copy operation
SECONDARY_STORAGE=$TEST_ZONE/SECONDARY_STORAGE
# Preference directory ( for testing the -pref-dir option) # Preference directory ( for testing the -pref-dir option)
DUPLICACY_PREF_DIR=$TEST_ZONE/TEST_DUPLICACY_PREF_DIR DUPLICACY_PREF_DIR=$TEST_ZONE/TEST_DUPLICACY_PREF_DIR
@@ -46,6 +49,11 @@ function fixture()
rm -rf $TEST_STORAGE rm -rf $TEST_STORAGE
mkdir -p $TEST_STORAGE mkdir -p $TEST_STORAGE
# clean SECONDARY_STORAGE
rm -rf $SECONDARY_STORAGE
mkdir -p $SECONDARY_STORAGE
# clean TEST_DOT_DUPLICACY # clean TEST_DOT_DUPLICACY
rm -rf $DUPLICACY_PREF_DIR rm -rf $DUPLICACY_PREF_DIR
mkdir -p $DUPLICACY_PREF_DIR mkdir -p $DUPLICACY_PREF_DIR
@@ -64,6 +72,7 @@ function init_repo()
{ {
pushd ${TEST_REPO} pushd ${TEST_REPO}
${DUPLICACY} init integration-tests $TEST_STORAGE ${DUPLICACY} init integration-tests $TEST_STORAGE
${DUPLICACY} add -copy default secondary integration-tests $SECONDARY_STORAGE
${DUPLICACY} backup ${DUPLICACY} backup
popd popd
@@ -73,6 +82,7 @@ function init_repo_pref_dir()
{ {
pushd ${TEST_REPO} pushd ${TEST_REPO}
${DUPLICACY} init -pref-dir "${DUPLICACY_PREF_DIR}" integration-tests ${TEST_STORAGE} ${DUPLICACY} init -pref-dir "${DUPLICACY_PREF_DIR}" integration-tests ${TEST_STORAGE}
${DUPLICACY} add -copy default secondary integration-tests $SECONDARY_STORAGE
${DUPLICACY} backup ${DUPLICACY} backup
popd popd
@@ -82,6 +92,7 @@ function add_file()
{ {
FILE_NAME=$1 FILE_NAME=$1
pushd ${TEST_REPO} pushd ${TEST_REPO}
dd if=/dev/urandom of=${FILE_NAME} bs=1000 count=20000
echo ${FILE_NAME} > "${FILE_NAME}" echo ${FILE_NAME} > "${FILE_NAME}"
popd popd
} }
@@ -91,6 +102,7 @@ function backup()
{ {
pushd ${TEST_REPO} pushd ${TEST_REPO}
${DUPLICACY} backup ${DUPLICACY} backup
${DUPLICACY} copy -from default -to secondary
popd popd
} }
@@ -100,4 +112,12 @@ function restore()
pushd ${TEST_REPO} pushd ${TEST_REPO}
${DUPLICACY} restore -r 2 -delete ${DUPLICACY} restore -r 2 -delete
popd popd
} }
function check()
{
pushd ${TEST_REPO}
${DUPLICACY} check -files
${DUPLICACY} check -storage secondary -files
popd
}

View File

@@ -1337,6 +1337,7 @@ func (manager *BackupManager) CopySnapshots(otherManager *BackupManager, snapsho
} else { } else {
LOG_INFO("SNAPSHOT_COPY", "Copied chunk %s (%d/%d)", chunk.GetID(), chunkIndex, len(chunks)) LOG_INFO("SNAPSHOT_COPY", "Copied chunk %s (%d/%d)", chunk.GetID(), chunkIndex, len(chunks))
} }
otherManager.config.PutChunk(chunk)
}) })
chunkUploader.Start() chunkUploader.Start()
@@ -1350,7 +1351,10 @@ func (manager *BackupManager) CopySnapshots(otherManager *BackupManager, snapsho
i := chunkDownloader.AddChunk(chunkHash) i := chunkDownloader.AddChunk(chunkHash)
chunk := chunkDownloader.WaitForChunk(i) chunk := chunkDownloader.WaitForChunk(i)
chunkUploader.StartChunk(chunk, chunkIndex) newChunk := otherManager.config.GetChunk()
newChunk.Reset(true)
newChunk.Write(chunk.GetBytes())
chunkUploader.StartChunk(newChunk, chunkIndex)
} }
chunkDownloader.Stop() chunkDownloader.Stop()