mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-02 06:02:53 +02:00
Resolve 'Directory not empty' issues on bulk deletes
* In some cases OneDrive does not send all delete changes or changes are out of order. When deleting local files, this can lead to a 'Directory not empty' error. This change adds to check for any remaining children of a directory that is to be deleted and delete them before
This commit is contained in:
parent
65a1181fcf
commit
6fe06d03ac
12
src/sync.d
12
src/sync.d
|
@ -596,16 +596,18 @@ final class SyncEngine
|
|||
itemdb.deleteById(item.remoteDriveId, item.remoteId);
|
||||
}
|
||||
if (exists(path)) {
|
||||
// path exists on the local system
|
||||
if (isFile(path)) {
|
||||
remove(path);
|
||||
} else {
|
||||
try {
|
||||
if (item.remoteDriveId == null) {
|
||||
rmdir(path);
|
||||
} else {
|
||||
// children of remote items are not enumerated
|
||||
rmdirRecurse(path);
|
||||
// Remove any children of this path if they still exist
|
||||
// Resolve 'Directory not empty' error when deleting local files
|
||||
foreach (DirEntry child; dirEntries(path, SpanMode.depth, false)) {
|
||||
attrIsDir(child.linkAttributes) ? rmdir(child.name) : remove(child.name);
|
||||
}
|
||||
// Remove the path now that it is empty of children
|
||||
rmdirRecurse(path);
|
||||
} catch (FileException e) {
|
||||
log.log(e.msg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue