Fix application crash when local file is changed to a symbolic link with non-existent target (#2211)

* Add a try & catch block for testing if the file exists locally to catch any filesystem error that may be generated
* Test path to be valid if a symbolic link
This commit is contained in:
abraunegg 2022-11-10 06:50:37 +11:00 committed by GitHub
parent 591b13f892
commit c73c0aa608
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2564,7 +2564,7 @@ final class SyncEngine
log.vdebug("OneDrive change is an update to an existing local item");
applyChangedItem(oldItem, oldPath, item, path);
} else {
log.vdebug("OneDrive change is a new local item");
log.vdebug("OneDrive change is potentially a new local item");
// Check if file should be skipped based on size limit
if (isItemFile(driveItem)) {
if (cfg.getValueLong("skip_size") != 0) {
@ -2621,7 +2621,33 @@ final class SyncEngine
// download an item that was not synced before
private void applyNewItem(const ref Item item, const(string) path)
{
if (exists(path)) {
bool localPathExists;
// Test for the local path existence
try {
// Does the path actually exist locally?
if (exists(path)) {
// flag that the path exists locally
localPathExists = true;
}
} catch (FileException e) {
// file system generated an error message
// display the error message
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
return;
}
if (localPathExists) {
// test if a bad symbolic link
if (isSymlink(path)) {
log.vdebug("Path on local disk is a symbolic link ........");
if (!exists(readLink(path))) {
// reading the symbolic link failed
log.vdebug("Reading the symbolic link target failed ........ ");
log.logAndNotify("Skipping item - invalid local symbolic link: ", path);
return;
}
}
// path exists locally
// Query DB for new remote item in specified path
string itemSource = "remote";