mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-13 11:22:39 +02:00
Update --single-directory handling for --dry-run and --resync (#856)
* Update --single-directory handling when using --dry-run * Update --single-directory handling when using --resync and items to sync are in a child folder rather than root, leading to parent database issues (foreign key constraint)
This commit is contained in:
parent
bed6e6bfe1
commit
0170884bd1
25
src/sync.d
25
src/sync.d
|
@ -2678,8 +2678,15 @@ final class SyncEngine
|
||||||
log.vlog("The requested directory to create was not found on OneDrive - creating remote directory: ", path);
|
log.vlog("The requested directory to create was not found on OneDrive - creating remote directory: ", path);
|
||||||
|
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
// Perform the database lookup
|
// Perform the database lookup - is the parent in the database?
|
||||||
|
if (!itemdb.selectByPath(dirName(path), parent.driveId, parent)) {
|
||||||
|
// parent is not in the database
|
||||||
|
log.vdebug("Parent path is not in the database - need to add it");
|
||||||
|
uploadCreateDir(dirName(path));
|
||||||
|
}
|
||||||
|
// still enforce check of parent path. if the above was triggered, the below will generate a sync retry and will now be sucessful
|
||||||
enforce(itemdb.selectByPath(dirName(path), parent.driveId, parent), "The parent item id is not in the database");
|
enforce(itemdb.selectByPath(dirName(path), parent.driveId, parent), "The parent item id is not in the database");
|
||||||
|
|
||||||
JSONValue driveItem = [
|
JSONValue driveItem = [
|
||||||
"name": JSONValue(baseName(path)),
|
"name": JSONValue(baseName(path)),
|
||||||
"folder": parseJSON("{}")
|
"folder": parseJSON("{}")
|
||||||
|
@ -2750,9 +2757,18 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// parent is in database
|
// parent is in database
|
||||||
log.vlog("The parent for this path is in the local database - adding requested path (", path ,") to database");
|
log.vlog("The parent for this path is in the local database - adding requested path (", path ,") to database");
|
||||||
|
|
||||||
|
// are we in a --dry-run scenario?
|
||||||
|
if (!dryRun) {
|
||||||
|
// get the live data
|
||||||
auto res = onedrive.getPathDetails(path);
|
auto res = onedrive.getPathDetails(path);
|
||||||
// Is the response a valid JSON object - validation checking done in saveItem
|
// Is the response a valid JSON object - validation checking done in saveItem
|
||||||
saveItem(res);
|
saveItem(res);
|
||||||
|
} else {
|
||||||
|
// need to fake this data
|
||||||
|
auto fakeResponse = createFakeResponse(path);
|
||||||
|
saveItem(fakeResponse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// They are the "same" name wise but different in case sensitivity
|
// They are the "same" name wise but different in case sensitivity
|
||||||
|
@ -3442,7 +3458,14 @@ final class SyncEngine
|
||||||
// Save the details of the file that we got from OneDrive
|
// Save the details of the file that we got from OneDrive
|
||||||
// --dry-run safe
|
// --dry-run safe
|
||||||
log.vlog("Updating the local database with details for this file: ", path);
|
log.vlog("Updating the local database with details for this file: ", path);
|
||||||
|
if (!dryRun) {
|
||||||
|
// use the live data
|
||||||
saveItem(fileDetailsFromOneDrive);
|
saveItem(fileDetailsFromOneDrive);
|
||||||
|
} else {
|
||||||
|
// need to fake this data
|
||||||
|
auto fakeResponse = createFakeResponse(path);
|
||||||
|
saveItem(fakeResponse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The files are the "same" name wise but different in case sensitivity
|
// The files are the "same" name wise but different in case sensitivity
|
||||||
|
|
Loading…
Reference in a new issue