mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-01 05:22:14 +02:00
Fix issue of silent exit when unable to delete local files when using --cleanup-local-files (#2227)
* Add try blocks for performing local deletes to catch in function permission issues preventing file|folder local deletion.
This commit is contained in:
parent
12d54db1e4
commit
5a7da61cbb
16
src/sync.d
16
src/sync.d
|
@ -4443,6 +4443,7 @@ final class SyncEngine
|
||||||
log.log("Removing local directory as --download-only & --cleanup-local-files configured");
|
log.log("Removing local directory as --download-only & --cleanup-local-files configured");
|
||||||
// Remove any children of this path if they still exist
|
// Remove any children of this path if they still exist
|
||||||
// Resolve 'Directory not empty' error when deleting local files
|
// Resolve 'Directory not empty' error when deleting local files
|
||||||
|
try {
|
||||||
foreach (DirEntry child; dirEntries(path, SpanMode.depth, false)) {
|
foreach (DirEntry child; dirEntries(path, SpanMode.depth, false)) {
|
||||||
// what sort of child is this?
|
// what sort of child is this?
|
||||||
if (isDir(child.name)) {
|
if (isDir(child.name)) {
|
||||||
|
@ -4453,7 +4454,12 @@ final class SyncEngine
|
||||||
// are we in a --dry-run scenario?
|
// are we in a --dry-run scenario?
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
// No --dry-run ... process local delete
|
// No --dry-run ... process local delete
|
||||||
|
try {
|
||||||
attrIsDir(child.linkAttributes) ? rmdir(child.name) : remove(child.name);
|
attrIsDir(child.linkAttributes) ? rmdir(child.name) : remove(child.name);
|
||||||
|
} catch (FileException e) {
|
||||||
|
// display the error message
|
||||||
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Remove the path now that it is empty of children
|
// Remove the path now that it is empty of children
|
||||||
|
@ -4461,7 +4467,17 @@ final class SyncEngine
|
||||||
// are we in a --dry-run scenario?
|
// are we in a --dry-run scenario?
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
// No --dry-run ... process local delete
|
// No --dry-run ... process local delete
|
||||||
|
try {
|
||||||
rmdirRecurse(path);
|
rmdirRecurse(path);
|
||||||
|
} catch (FileException e) {
|
||||||
|
// display the error message
|
||||||
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (FileException e) {
|
||||||
|
// display the error message
|
||||||
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue