Skip to content

Conversation

@alperozturk96
Copy link
Collaborator

@alperozturk96 alperozturk96 commented Dec 18, 2025

  • Tests written, or not not needed

Previous logic before metadata worker implementation:

mRemoteFolderChanged = !(remoteFolderETag.equalsIgnoreCase(localFolderEtag));

private RemoteOperationResult checkForChanges(OwnCloudClient client) {
        mRemoteFolderChanged = true;
        RemoteOperationResult result;
        String remotePath = mLocalFolder.getRemotePath();

        Log_OC.d(TAG, "Checking changes in " + user.getAccountName() + remotePath);

        // remote request
        result = new ReadFileRemoteOperation(remotePath).execute(client);

        if (result.isSuccess()) {
            if (!mIgnoreETag && result.getData().get(0) instanceof RemoteFile remoteFile) {
                // check if remote and local folder are different
                String remoteFolderETag = remoteFile.getEtag();
                if (remoteFolderETag != null) {
                    String localFolderEtag = mLocalFolder.getEtag();
                    mRemoteFolderChanged = !(remoteFolderETag.equalsIgnoreCase(localFolderEtag));
                    Log_OC.d(
                        TAG,
                        "📂 eTag check\n" +
                            "  Path:        " + remoteFile.getRemotePath() + "\n" +
                            "  Local eTag:  " + localFolderEtag + "\n" +
                            "  Remote eTag: " + remoteFolderETag + "\n" +
                            "  Changed:     " + mRemoteFolderChanged
                            );
                } else {
                    Log_OC.e(TAG, "Checked " + user.getAccountName() + remotePath + ": No ETag received from server");
                }
            } else {
                Log_OC.d(TAG, "Ignoring eTag. mRemoteFolderChanged is true.");
            }

            result = new RemoteOperationResult(ResultCode.OK);

            Log_OC.i(TAG, "Checked " + user.getAccountName() + remotePath + " : " +
                (mRemoteFolderChanged ? "changed" : "not changed"));

        } else {
            // check failed
            if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
                removeLocalFolder();
            }
            if (result.isException()) {
                Log_OC.e(TAG, "Checked " + user.getAccountName() + remotePath + " : " +
                    result.getLogMessage(), result.getException());
            } else {
                Log_OC.e(TAG, "Checked " + user.getAccountName() + remotePath + " : " +
                    result.getLogMessage());
            }
        }

        return result;
    }

@alperozturk96
Copy link
Collaborator Author

/backport to stable-3.35


@Test
fun testIsNotBlankAndEqualsWhenGivenOneHasLeadingWhitespaceAndOtherDoesNot() {
val str1 = " hello"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove spaces and compare just like before.


@Test
fun testIsNotBlankAndEqualsWhenGivenBothHaveIdenticalWhitespacePaddingDifferentCase() {
val str1 = " hello "
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If even spaces are same and content is same we can consider as eTag didnt change

@github-actions
Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16164.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

Signed-off-by: alperozturk <[email protected]>
Signed-off-by: alperozturk <[email protected]>
Signed-off-by: alperozturk <[email protected]>
Signed-off-by: alperozturk <[email protected]>
@github-actions
Copy link

Codacy

SpotBugs

CategoryBaseNew
Bad practice4343
Correctness7373
Dodgy code257257
Experimental11
Internationalization77
Malicious code vulnerability33
Multithreaded correctness3434
Performance4343
Security1818
Total479479

@alperozturk96 alperozturk96 merged commit 3f5b20b into master Dec 18, 2025
13 of 20 checks passed
@alperozturk96 alperozturk96 deleted the fix/e-tag-comparasion branch December 18, 2025 15:22
@github-actions
Copy link

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@alperozturk96 alperozturk96 added this to the Nextcloud App 3.35.0 milestone Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants