mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-02 22:12:33 +02:00
Fix file kept in database when using --no-remote-delete & --remove-source-files (#1383)
* Fix file kept in database when using --no-remote-delete & --remove-source-files
This commit is contained in:
parent
b1b814f10a
commit
1203aebeb7
14
src/sync.d
14
src/sync.d
|
@ -4011,10 +4011,8 @@ final class SyncEngine
|
||||||
if (!uploadFailed) {
|
if (!uploadFailed) {
|
||||||
// Upload did not fail
|
// Upload did not fail
|
||||||
// Issue #763 - Delete local files after sync handling
|
// Issue #763 - Delete local files after sync handling
|
||||||
// are we in an --upload-only scenario?
|
// are we in an --upload-only & --remove-source-files scenario?
|
||||||
if (uploadOnly) {
|
if ((uploadOnly) && (localDeleteAfterUpload)) {
|
||||||
// are we in a delete local file after upload?
|
|
||||||
if (localDeleteAfterUpload) {
|
|
||||||
// Log that we are deleting a local item
|
// Log that we are deleting a local item
|
||||||
log.log("Removing local file as --upload-only & --remove-source-files configured");
|
log.log("Removing local file as --upload-only & --remove-source-files configured");
|
||||||
// are we in a --dry-run scenario?
|
// are we in a --dry-run scenario?
|
||||||
|
@ -4026,7 +4024,6 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// path is not a valid file
|
// path is not a valid file
|
||||||
log.log("Skipping item - item is not a valid file: ", path);
|
log.log("Skipping item - item is not a valid file: ", path);
|
||||||
|
@ -5301,11 +5298,18 @@ final class SyncEngine
|
||||||
if (jsonItem.type() == JSONType.object){
|
if (jsonItem.type() == JSONType.object){
|
||||||
// Check if the response JSON has an 'id', otherwise makeItem() fails with 'Key not found: id'
|
// Check if the response JSON has an 'id', otherwise makeItem() fails with 'Key not found: id'
|
||||||
if (hasId(jsonItem)) {
|
if (hasId(jsonItem)) {
|
||||||
|
// 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.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
|
// Takes a JSON input and formats to an item which can be used by the database
|
||||||
Item item = makeItem(jsonItem);
|
Item item = makeItem(jsonItem);
|
||||||
// Add to the local database
|
// Add to the local database
|
||||||
log.vdebug("Adding to database: ", item);
|
log.vdebug("Adding to database: ", item);
|
||||||
itemdb.upsert(item);
|
itemdb.upsert(item);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// log error
|
// log error
|
||||||
log.error("ERROR: OneDrive response missing required 'id' element");
|
log.error("ERROR: OneDrive response missing required 'id' element");
|
||||||
|
|
Loading…
Reference in a new issue