Skip to content

Commit

Permalink
Resolve that upload session are not canceled with resync option
Browse files Browse the repository at this point in the history
* Resolve that upload session are not canceled with resync option
  • Loading branch information
abraunegg committed Feb 11, 2024
1 parent 83726ac commit d2a78be
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,17 @@ int main(string[] cliArgs) {
string localPath = ".";
string remotePath = "/";

// Check if there are interrupted upload session(s)
if (syncEngineInstance.checkForInterruptedSessionUploads) {
// Need to re-process the session upload files to resume the failed session uploads
addLogEntry("There are interrupted session uploads that need to be resumed ...");
// Process the session upload files
syncEngineInstance.processForInterruptedSessionUploads();
if (!appConfig.getValueBool("resync")) {
// Check if there are interrupted upload session(s)
if (syncEngineInstance.checkForInterruptedSessionUploads) {
// Need to re-process the session upload files to resume the failed session uploads
addLogEntry("There are interrupted session uploads that need to be resumed ...");
// Process the session upload files
syncEngineInstance.processForInterruptedSessionUploads();
}
} else {
// Clean up any upload session files due to --resync being used
syncEngineInstance.clearInterruptedSessionUploads();
}

// Are we doing a single directory operation (--single-directory) ?
Expand Down
16 changes: 16 additions & 0 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -7588,6 +7588,22 @@ class SyncEngine {
return interruptedUploads;
}

// Clear any session_upload.* files
void clearInterruptedSessionUploads() {
// Scan the filesystem for the files we are interested in, build up interruptedUploadsSessionFiles array
foreach (sessionFile; dirEntries(appConfig.configDirName, "session_upload.*", SpanMode.shallow)) {
// calculate the full path
string tempPath = buildNormalizedPath(buildPath(appConfig.configDirName, sessionFile));
JSONValue sessionFileData = readText(tempPath).parseJSON();
addLogEntry("Removing interrupted session upload file due to --resync for: " ~ sessionFileData["localPath"].str, ["info"]);

// Process removal
if (!dryRun) {
safeRemove(tempPath);
}
}
}

// Process interrupted 'session_upload' files
void processForInterruptedSessionUploads() {
// For each upload_session file that has been found, process the data to ensure it is still valid
Expand Down

0 comments on commit d2a78be

Please sign in to comment.