Skip to content

Commit 472149b

Browse files
Merge pull request #14047 from nextcloud/backport/14044/stable-3.30
[stable-3.30] two way sync: save updated etag
2 parents 1ef97d4 + c1f24dc commit 472149b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Diff for: app/src/main/java/com/owncloud/android/operations/SynchronizeFolderOperation.java

+22-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
138138
}
139139

140140
if (result.isSuccess()) {
141-
syncContents();
141+
syncContents(client);
142142
}
143143
}
144144

@@ -440,9 +440,29 @@ private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
440440
}
441441
}
442442

443-
private void syncContents() throws OperationCancelledException {
443+
private void syncContents(OwnCloudClient client) throws OperationCancelledException {
444444
startDirectDownloads();
445445
startContentSynchronizations(mFilesToSyncContents);
446+
updateETag(client);
447+
}
448+
449+
/**
450+
* Updates the eTag of the local folder after a successful synchronization.
451+
* This ensures that any changes to local files, which may alter the eTag, are correctly reflected.
452+
*
453+
* @param client the OwnCloudClient instance used to execute remote operations.
454+
*/
455+
private void updateETag(OwnCloudClient client) {
456+
ReadFolderRemoteOperation operation = new ReadFolderRemoteOperation(mRemotePath);
457+
final var result = operation.execute(client);
458+
459+
if (result.getData().get(0) instanceof RemoteFile remoteFile) {
460+
String eTag = remoteFile.getEtag();
461+
mLocalFolder.setEtag(eTag);
462+
463+
final FileDataStorageManager storageManager = getStorageManager();
464+
storageManager.saveFile(mLocalFolder);
465+
}
446466
}
447467

448468
private void startDirectDownloads() {

0 commit comments

Comments
 (0)