Only set xattr values when not using --dry-run (#3290)

* We can only set xattr values when not performing a --dry-run operation, as if we are doing --download-only --dry-run .. there is no file locally to set attributes on
This commit is contained in:
abraunegg 2025-05-24 12:28:35 +10:00 committed by GitHub
commit 8f82919e5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3918,33 +3918,35 @@ class SyncEngine {
displayFunctionProcessingStart(thisFunctionName, logKey);
}
// This function will write the following xattr attributes based on the JSON data received from Microsoft onedrive
// - createdBy using the 'displayName' value
// - lastModifiedBy using the 'displayName' value
string createdBy;
string lastModifiedBy;
// Configure 'createdBy' from the JSON data
if (hasCreatedByUserDisplayName(onedriveJSONItem)) {
createdBy = onedriveJSONItem["createdBy"]["user"]["displayName"].str;
} else {
// required data not in JSON data
createdBy = "Unknown";
// We can only set xattr values when not performing a --dry-run operation
if (!dryRun) {
// This function will write the following xattr attributes based on the JSON data received from Microsoft onedrive
// - createdBy using the 'displayName' value
// - lastModifiedBy using the 'displayName' value
string createdBy;
string lastModifiedBy;
// Configure 'createdBy' from the JSON data
if (hasCreatedByUserDisplayName(onedriveJSONItem)) {
createdBy = onedriveJSONItem["createdBy"]["user"]["displayName"].str;
} else {
// required data not in JSON data
createdBy = "Unknown";
}
// Configure 'lastModifiedBy' from the JSON data
if (hasLastModifiedByUserDisplayName(onedriveJSONItem)) {
lastModifiedBy = onedriveJSONItem["lastModifiedBy"]["user"]["displayName"].str;
} else {
// required data not in JSON data
lastModifiedBy = "Unknown";
}
// Set the xattr values
setXAttr(filePath, "user.onedrive.createdBy", createdBy);
setXAttr(filePath, "user.onedrive.lastModifiedBy", lastModifiedBy);
}
// Configure 'lastModifiedBy' from the JSON data
if (hasLastModifiedByUserDisplayName(onedriveJSONItem)) {
lastModifiedBy = onedriveJSONItem["lastModifiedBy"]["user"]["displayName"].str;
} else {
// required data not in JSON data
lastModifiedBy = "Unknown";
}
// Set the xattr values
setXAttr(filePath, "user.onedrive.createdBy", createdBy);
setXAttr(filePath, "user.onedrive.lastModifiedBy", lastModifiedBy);
// Display function processing time if configured to do so
if (appConfig.getValueBool("display_processing_time") && debugLogging) {
// Combine module name & running Function