Skip to content

Commit

Permalink
Merge pull request #14047 from nextcloud/backport/14044/stable-3.30
Browse files Browse the repository at this point in the history
[stable-3.30] two way sync: save updated etag
  • Loading branch information
tobiasKaminsky authored Nov 18, 2024
2 parents 1ef97d4 + c1f24dc commit 472149b
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
}

if (result.isSuccess()) {
syncContents();
syncContents(client);
}
}

Expand Down Expand Up @@ -440,9 +440,29 @@ private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
}
}

private void syncContents() throws OperationCancelledException {
private void syncContents(OwnCloudClient client) throws OperationCancelledException {
startDirectDownloads();
startContentSynchronizations(mFilesToSyncContents);
updateETag(client);
}

/**
* Updates the eTag of the local folder after a successful synchronization.
* This ensures that any changes to local files, which may alter the eTag, are correctly reflected.
*
* @param client the OwnCloudClient instance used to execute remote operations.
*/
private void updateETag(OwnCloudClient client) {
ReadFolderRemoteOperation operation = new ReadFolderRemoteOperation(mRemotePath);
final var result = operation.execute(client);

if (result.getData().get(0) instanceof RemoteFile remoteFile) {
String eTag = remoteFile.getEtag();
mLocalFolder.setEtag(eTag);

final FileDataStorageManager storageManager = getStorageManager();
storageManager.saveFile(mLocalFolder);
}
}

private void startDirectDownloads() {
Expand Down

0 comments on commit 472149b

Please sign in to comment.