mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-09 09:16:42 +02:00
Fix that options --upload-only & --remove-source-files are ignored on an upload session restore (#1399)
* Fix that options --upload-only & --remove-source-files are ignored on an upload session restore
This commit is contained in:
parent
068f8a6917
commit
b7eedbd8cd
37
src/sync.d
37
src/sync.d
|
@ -445,9 +445,40 @@ final class SyncEngine
|
|||
// Check if there is an interrupted upload session
|
||||
if (session.restore()) {
|
||||
log.log("Continuing the upload session ...");
|
||||
string uploadSessionLocalFilePath = session.getUploadSessionLocalFilePath();
|
||||
auto item = session.upload();
|
||||
saveItem(item);
|
||||
}
|
||||
|
||||
// is 'item' a valid JSON response and not null
|
||||
if (item.type() == JSONType.object) {
|
||||
// Upload did not fail, JSON response contains data
|
||||
// Are we in an --upload-only & --remove-source-files scenario?
|
||||
// Use actual config values as we are doing an upload session recovery
|
||||
if ((cfg.getValueBool("upload_only")) && (cfg.getValueBool("remove_source_files"))) {
|
||||
// Log that we are deleting a local item
|
||||
log.log("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
|
||||
if (!uploadSessionLocalFilePath.empty) {
|
||||
// only perform the delete if we have a valid file path
|
||||
if (exists(uploadSessionLocalFilePath)) {
|
||||
// file exists
|
||||
log.vdebug("Removing local file: ", uploadSessionLocalFilePath);
|
||||
safeRemove(uploadSessionLocalFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
// as file is removed, we have nothing to add to the local database
|
||||
log.vdebug("Skipping adding to database as --upload-only & --remove-source-files configured");
|
||||
} else {
|
||||
// save the item
|
||||
saveItem(item);
|
||||
}
|
||||
} else {
|
||||
// JSON response was not valid, upload failed
|
||||
log.error("ERROR: File failed to upload. Increase logging verbosity to determine why.");
|
||||
}
|
||||
}
|
||||
initDone = true;
|
||||
} else {
|
||||
// init failure
|
||||
|
@ -5321,7 +5352,7 @@ final class SyncEngine
|
|||
// Are we in a --upload-only & --remove-source-files scenario?
|
||||
// We do not want to add the item to the database in this situation as there is no local reference to the file post file deletion
|
||||
if ((uploadOnly) && (localDeleteAfterUpload)) {
|
||||
// Log that we are deleting a local item
|
||||
// Log that we skipping adding item to the local DB and the reason why
|
||||
log.vdebug("Skipping adding to database as --upload-only & --remove-source-files configured");
|
||||
} else {
|
||||
// Takes a JSON input and formats to an item which can be used by the database
|
||||
|
|
|
@ -268,6 +268,15 @@ struct UploadSession
|
|||
}
|
||||
}
|
||||
|
||||
string getUploadSessionLocalFilePath() {
|
||||
// return the session file path
|
||||
string localPath = "";
|
||||
if ("localPath" in session){
|
||||
localPath = session["localPath"].str;
|
||||
}
|
||||
return localPath;
|
||||
}
|
||||
|
||||
// save session details to temp file
|
||||
private void save()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue