Skip to content

Commit

Permalink
Fix issue #2830
Browse files Browse the repository at this point in the history
* Fix regression that --remove-source-files doesn’t work
  • Loading branch information
abraunegg committed Sep 20, 2024
1 parent fb35508 commit a205d39
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -5729,7 +5729,6 @@ class SyncEngine {
if (!uploadFailed) {
// Update the 'cachedOnlineDriveData' record for this 'dbItem.driveId' so that this is tracked as accurately as possible for other threads
updateDriveDetailsCache(parentItem.driveId, cachedOnlineDriveData.quotaRestricted, cachedOnlineDriveData.quotaAvailable, thisFileSize);

} else {
// Need to add this to fileUploadFailures to capture at the end
fileUploadFailures ~= fileToUpload;
Expand Down Expand Up @@ -5923,6 +5922,7 @@ class SyncEngine {
if (uploadResponse.type() == JSONType.object) {
// check if the path still exists locally before we try to set the file times online - as short lived files, whilst we uploaded it - it may not exist locally already
if (exists(fileToUpload)) {
// Are we in a --dry-run scenario
if (!dryRun) {
// Check the integrity of the uploaded file, if the local file still exists
performUploadIntegrityValidationChecks(uploadResponse, fileToUpload, thisFileSize);
Expand All @@ -5936,6 +5936,19 @@ class SyncEngine {
// Attempt to update the online date time stamp based on our local data
uploadLastModifiedTime(parentItem, parentItem.driveId, newFileId, mtime, newFileETag);
}

// Are we in an --upload-only & --remove-source-files scenario?
// Use actual config values as we are doing an upload session recovery
if (localDeleteAfterUpload) {
// Log that we are deleting a local item
addLogEntry("Removing local file as --upload-only & --remove-source-files configured");
// Are we in a --dry-run scenario?
if (!dryRun) {
// No --dry-run ... process local file delete
addLogEntry("Removing local file: " ~ fileToUpload, ["debug"]);
safeRemove(fileToUpload);
}
}
} else {
// will be removed in different event!
addLogEntry("File disappeared locally after upload: " ~ fileToUpload);
Expand Down

0 comments on commit a205d39

Please sign in to comment.