Skip to content

Commit 8f82919

Browse files
authored
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
1 parent 3394183 commit 8f82919

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

src/sync.d

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3918,33 +3918,35 @@ class SyncEngine {
39183918
displayFunctionProcessingStart(thisFunctionName, logKey);
39193919
}
39203920

3921-
// This function will write the following xattr attributes based on the JSON data received from Microsoft onedrive
3922-
// - createdBy using the 'displayName' value
3923-
// - lastModifiedBy using the 'displayName' value
3924-
3925-
string createdBy;
3926-
string lastModifiedBy;
3927-
3928-
// Configure 'createdBy' from the JSON data
3929-
if (hasCreatedByUserDisplayName(onedriveJSONItem)) {
3930-
createdBy = onedriveJSONItem["createdBy"]["user"]["displayName"].str;
3931-
} else {
3932-
// required data not in JSON data
3933-
createdBy = "Unknown";
3934-
}
3935-
3936-
// Configure 'lastModifiedBy' from the JSON data
3937-
if (hasLastModifiedByUserDisplayName(onedriveJSONItem)) {
3938-
lastModifiedBy = onedriveJSONItem["lastModifiedBy"]["user"]["displayName"].str;
3939-
} else {
3940-
// required data not in JSON data
3941-
lastModifiedBy = "Unknown";
3921+
// We can only set xattr values when not performing a --dry-run operation
3922+
if (!dryRun) {
3923+
// This function will write the following xattr attributes based on the JSON data received from Microsoft onedrive
3924+
// - createdBy using the 'displayName' value
3925+
// - lastModifiedBy using the 'displayName' value
3926+
string createdBy;
3927+
string lastModifiedBy;
3928+
3929+
// Configure 'createdBy' from the JSON data
3930+
if (hasCreatedByUserDisplayName(onedriveJSONItem)) {
3931+
createdBy = onedriveJSONItem["createdBy"]["user"]["displayName"].str;
3932+
} else {
3933+
// required data not in JSON data
3934+
createdBy = "Unknown";
3935+
}
3936+
3937+
// Configure 'lastModifiedBy' from the JSON data
3938+
if (hasLastModifiedByUserDisplayName(onedriveJSONItem)) {
3939+
lastModifiedBy = onedriveJSONItem["lastModifiedBy"]["user"]["displayName"].str;
3940+
} else {
3941+
// required data not in JSON data
3942+
lastModifiedBy = "Unknown";
3943+
}
3944+
3945+
// Set the xattr values
3946+
setXAttr(filePath, "user.onedrive.createdBy", createdBy);
3947+
setXAttr(filePath, "user.onedrive.lastModifiedBy", lastModifiedBy);
39423948
}
39433949

3944-
// Set the xattr values
3945-
setXAttr(filePath, "user.onedrive.createdBy", createdBy);
3946-
setXAttr(filePath, "user.onedrive.lastModifiedBy", lastModifiedBy);
3947-
39483950
// Display function processing time if configured to do so
39493951
if (appConfig.getValueBool("display_processing_time") && debugLogging) {
39503952
// Combine module name & running Function

0 commit comments

Comments
 (0)