mirror of
https://github.com/abraunegg/onedrive
synced 2026-03-14 14:35:46 +01:00
Fix Bug #3501: When using --dry-run use tracked renamed directories
* When using --dry-run use tracked renamed directories to avoid falsely indicating local data is new and uploading as new data
This commit is contained in:
parent
1e48e42363
commit
6208be7645
3 changed files with 55 additions and 12 deletions
|
|
@ -706,7 +706,7 @@ class ApplicationConfig {
|
|||
}
|
||||
} else {
|
||||
// --dry-run scenario ... technically we should not be making any local file changes .......
|
||||
addLogEntry("DRY RUN: Not creating backup config file as --dry-run has been used");
|
||||
addLogEntry("DRY-RUN: Not creating backup config file as --dry-run has been used");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2120,7 +2120,7 @@ class ApplicationConfig {
|
|||
safeRemove(syncListHashFile);
|
||||
} else {
|
||||
// --dry-run scenario ... technically we should not be making any local file changes .......
|
||||
addLogEntry("DRY RUN: Not removing hash files as --dry-run has been used");
|
||||
addLogEntry("DRY-RUN: Not removing hash files as --dry-run has been used");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2157,7 +2157,7 @@ class ApplicationConfig {
|
|||
}
|
||||
} else {
|
||||
// --dry-run scenario ... technically we should not be making any local file changes .......
|
||||
addLogEntry("DRY RUN: Not updating hash files as --dry-run has been used");
|
||||
addLogEntry("DRY-RUN: Not updating hash files as --dry-run has been used");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ int main(string[] cliArgs) {
|
|||
safeRemove(appConfig.intuneAccountDetailsFilePath);
|
||||
} else {
|
||||
// --dry-run scenario ... technically we should not be making any local file changes .......
|
||||
addLogEntry("DRY RUN: Not removing the saved authentication status");
|
||||
addLogEntry("DRY-RUN: Not removing the saved authentication status");
|
||||
}
|
||||
// Exit
|
||||
return EXIT_SUCCESS;
|
||||
|
|
@ -481,7 +481,7 @@ int main(string[] cliArgs) {
|
|||
safeRemove(appConfig.intuneAccountDetailsFilePath);
|
||||
} else {
|
||||
// --dry-run scenario ... technically we should not be making any local file changes .......
|
||||
addLogEntry("DRY RUN: Not removing the saved authentication status");
|
||||
addLogEntry("DRY-RUN: Not removing the saved authentication status");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1719,7 +1719,7 @@ void processResyncDatabaseRemoval(string databaseFilePathToRemove) {
|
|||
safeRemove(databaseFilePathToRemove);
|
||||
} else {
|
||||
// --dry-run scenario ... technically we should not be making any local file changes .......
|
||||
addLogEntry("DRY RUN: Not removing the saved application sync status");
|
||||
addLogEntry("DRY-RUN: Not removing the saved application sync status");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
55
src/sync.d
55
src/sync.d
|
|
@ -5296,13 +5296,26 @@ class SyncEngine {
|
|||
// We are in a --dry-run situation, file appears to have been deleted locally - this file may never have existed locally as we never downloaded it due to --dry-run
|
||||
// Did we 'fake create it' as part of --dry-run ?
|
||||
bool idsFakedMatch = false;
|
||||
|
||||
// Check the file id - was this faked
|
||||
foreach (i; idsFaked) {
|
||||
if (i[1] == dbItem.id) {
|
||||
if (debugLogging) {addLogEntry("Matched faked file which is 'supposed' to exist but not created due to --dry-run use", ["debug"]);}
|
||||
if (debugLogging) {addLogEntry("Matched faked file which is 'supposed' to exist locally but not created|renamed due to --dry-run use", ["debug"]);}
|
||||
if (verboseLogging) {addLogEntry("The file has not changed", ["verbose"]);}
|
||||
idsFakedMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the parent folder was faked being changed in any way .. so we need to check the parent id
|
||||
foreach (i; idsFaked) {
|
||||
if (i[1] == dbItem.parentId) {
|
||||
if (debugLogging) {addLogEntry("Matched faked parental directory which is 'supposed' to exist locally but not created|renamed due to --dry-run use", ["debug"]);}
|
||||
if (verboseLogging) {addLogEntry("The file has not changed", ["verbose"]);}
|
||||
idsFakedMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
// file id or parent id of the file did not match anything we faked changing due to --dry-run
|
||||
if (!idsFakedMatch) {
|
||||
// dbItem.id did not match a 'faked' download new file creation - so this in-sync object was actually deleted locally, but we are in a --dry-run situation
|
||||
if (verboseLogging) {addLogEntry("The file has been deleted locally", ["verbose"]);}
|
||||
|
|
@ -5384,7 +5397,7 @@ class SyncEngine {
|
|||
bool idsFakedMatch = false;
|
||||
foreach (i; idsFaked) {
|
||||
if (i[1] == dbItem.id) {
|
||||
if (debugLogging) {addLogEntry("Matched faked dir which is 'supposed' to exist but not created due to --dry-run use", ["debug"]);}
|
||||
if (debugLogging) {addLogEntry("Matched faked directory which is 'supposed' to exist locally but not created|renamed due to --dry-run use", ["debug"]);}
|
||||
if (verboseLogging) {addLogEntry("The directory has not changed", ["verbose"]);}
|
||||
idsFakedMatch = true;
|
||||
}
|
||||
|
|
@ -7369,11 +7382,26 @@ class SyncEngine {
|
|||
// We can never add or create online the OneDrive 'root'
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Only add unique paths
|
||||
if (!pathsToCreateOnline.canFind(pathToAdd)) {
|
||||
// Add this unique path to the created online
|
||||
pathsToCreateOnline ~= pathToAdd;
|
||||
|
||||
// are we in a --dry-run scenario?
|
||||
if (!dryRun) {
|
||||
// Add this to the list to create online
|
||||
pathsToCreateOnline ~= pathToAdd;
|
||||
} else {
|
||||
// We are in a --dry-run scenario .. this might have been a directory we 'faked' doing something with.
|
||||
// pathsRenamed contains all the paths that were 'renamed'
|
||||
if (pathsRenamed.canFind(pathToAdd)) {
|
||||
// Path was renamed .. but faked due to --dry-run
|
||||
if (debugLogging) {addLogEntry("DRY-RUN: Skipping creating this directory online as this was a faked local change", ["debug"]);}
|
||||
} else {
|
||||
// Add this to the list to create online
|
||||
pathsToCreateOnline ~= pathToAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -7778,12 +7806,27 @@ class SyncEngine {
|
|||
// Ensure this directory on OneDrive so that we can upload files to it
|
||||
// Add this path to an array so that the directory online can be created before we upload files
|
||||
string parentPath = dirName(path);
|
||||
|
||||
if (debugLogging) {addLogEntry("Adding parental path to create online (file inclusion): " ~ parentPath, ["debug"]);}
|
||||
addPathToCreateOnline(parentPath);
|
||||
|
||||
// Add this path as a file we need to upload
|
||||
if (debugLogging) {addLogEntry("OneDrive Client flagging to upload this file to Microsoft OneDrive: " ~ path, ["debug"]);}
|
||||
newLocalFilesToUploadToOneDrive ~= path;
|
||||
|
||||
if (!dryRun) {
|
||||
// Add to the array
|
||||
newLocalFilesToUploadToOneDrive ~= path;
|
||||
} else {
|
||||
// In a --dry-run scenario, we may have locally fake changed a directory name, thus, this path we are checking needs to checked against 'pathsRenamed'
|
||||
if (pathsRenamed.canFind(parentPath)) {
|
||||
// Parental path was renamed
|
||||
if (debugLogging) {addLogEntry("DRY-RUN: parentPath found in 'pathsRenamed' ... skipping uploading this file", ["debug"]);}
|
||||
} else {
|
||||
// Add to the array
|
||||
newLocalFilesToUploadToOneDrive ~= path;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// we need to clean up this file
|
||||
addLogEntry("Removing local file as --download-only & --cleanup-local-files configured");
|
||||
|
|
@ -10002,7 +10045,7 @@ class SyncEngine {
|
|||
}
|
||||
} else {
|
||||
// log that this is a dry-run activity
|
||||
addLogEntry("dry run - no delete activity");
|
||||
addLogEntry("DRY-RUN: No delete activity");
|
||||
}
|
||||
} else {
|
||||
// --download-only operation, we are not uploading any delete event to OneDrive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue