Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Operation not permitted FileException Error #2958

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -2601,7 +2601,12 @@ class SyncEngine {
// set the correct time on the downloaded file
if (!dryRun) {
if (debugLogging) {addLogEntry("Calling setTimes() for this file: " ~ newItemPath, ["debug"]);}
setTimes(newItemPath, itemModifiedTime, itemModifiedTime);
try {
setTimes(newItemPath, itemModifiedTime, itemModifiedTime);
} catch (FileException e) {
// display the error message
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
}
}
} catch (FileException e) {
// display the error message
Expand Down Expand Up @@ -2765,7 +2770,12 @@ class SyncEngine {
if (verboseLogging) {addLogEntry("The source of the incorrect timestamp was the local file - correcting timestamp locally due to --resync", ["verbose"]);}
// Fix the local file timestamp
if (debugLogging) {addLogEntry("Calling setTimes() for this file: " ~ path, ["debug"]);}
setTimes(path, item.mtime, item.mtime);
try {
setTimes(path, item.mtime, item.mtime);
} catch (FileException e) {
// display the error message
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
}
} else {
// The source of the out-of-date timestamp was OneDrive and this needs to be corrected to avoid always generating a hash test if timestamp is different
if (verboseLogging) {addLogEntry("The source of the incorrect timestamp was OneDrive online - correcting timestamp online", ["verbose"]);}
Expand All @@ -2784,14 +2794,24 @@ class SyncEngine {
if (verboseLogging) {addLogEntry("The source of the incorrect timestamp was the local file - correcting timestamp locally due to --download-only", ["verbose"]);}
// Fix the local file timestamp
if (debugLogging) {addLogEntry("Calling setTimes() for this file: " ~ path, ["debug"]);}
setTimes(path, item.mtime, item.mtime);
try {
setTimes(path, item.mtime, item.mtime);
} catch (FileException e) {
// display the error message
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
}
}
} else if (!dryRun) {
// The source of the out-of-date timestamp was the local file and this needs to be corrected to avoid always generating a hash test if timestamp is different
if (verboseLogging) {addLogEntry("The source of the incorrect timestamp was the local file - correcting timestamp locally", ["verbose"]);}
// Fix the local file timestamp
if (debugLogging) {addLogEntry("Calling setTimes() for this file: " ~ path, ["debug"]);}
setTimes(path, item.mtime, item.mtime);
try {
setTimes(path, item.mtime, item.mtime);
} catch (FileException e) {
// display the error message
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
}
}
return false;
} else {
Expand Down Expand Up @@ -3401,15 +3421,25 @@ class SyncEngine {
// Remote file, remote values need to be used, we may not even have permission to change timestamp, update local file
if (verboseLogging) {addLogEntry("The local item has the same hash value as the item online, however file is a OneDrive Business Shared File - correcting local timestamp", ["verbose"]);}
if (debugLogging) {addLogEntry("Calling setTimes() for this file: " ~ localFilePath, ["debug"]);}
setTimes(localFilePath, dbItem.mtime, dbItem.mtime);
try {
setTimes(localFilePath, dbItem.mtime, dbItem.mtime);
} catch (FileException e) {
// display the error message
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
}
}
}
} else {
// --download-only being used
if (verboseLogging) {addLogEntry("The local item has the same hash value as the item online - correcting local timestamp due to --download-only being used to ensure local file matches timestamp online", ["verbose"]);}
if (!dryRun) {
if (debugLogging) {addLogEntry("Calling setTimes() for this file: " ~ localFilePath, ["debug"]);}
setTimes(localFilePath, dbItem.mtime, dbItem.mtime);
try {
setTimes(localFilePath, dbItem.mtime, dbItem.mtime);
} catch (FileException e) {
// display the error message
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
}
}
}
}
Expand Down
Loading