Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cancel upload in case of name collision in autoupload #6911

Open
dassio opened this issue Sep 8, 2020 · 7 comments
Open

Add cancel upload in case of name collision in autoupload #6911

dassio opened this issue Sep 8, 2020 · 7 comments

Comments

@dassio
Copy link
Contributor

dassio commented Sep 8, 2020

Is your feature request related to a problem? Please describe.

I'm always frustrated when I uninstall and reinstall the app when I turn on the auto-upload, it will reupload all the 1000+ pictures on my phone, now I know the pictures have not been changed so in case of name collision, I would like to cancel the upload

Describe the solution you'd like

add option Cancle Upload besides of :

<string name="pref_instant_name_collision_policy_entries_always_ask">Ask me every time</string>
 <string name="pref_instant_name_collision_policy_entries_rename">Rename new version</string>
  <string name="pref_instant_name_collision_policy_entries_overwrite">Overwrite remote version</string>

Additional context

this could be extened on this #5810

NOTE: Be super sure to remove sensitive data like passwords, note that everybody can look here! You can use the Issue Template application to prefill some of the required information: https://apps.nextcloud.com/apps/issuetemplate

@AndyScherzinger
Copy link
Member

@tobiasKaminsky I guess there should be a skip file if exists option (instead of cancel which might be misleading)

@tobiasKaminsky
Copy link
Member

Yes, in the auto upload it should be named
"skip if file with same name exists"

@AndyScherzinger
Copy link
Member

@tobiasKaminsky AFAIK we don't have this option yet

@dassio
Copy link
Contributor Author

dassio commented Sep 23, 2020

@tobiasKaminsky AFAIK we don't have this option yet

I see the logic is already in place, I give a test by just adding the menu, it seems to be working fine.
https://github.com/nextcloud/android/blob/master/src/main/java/com/owncloud/android/operations/UploadFileOperation.java

@CheckResult
    private RemoteOperationResult checkNameCollision(OwnCloudClient client,
                                                     DecryptedFolderMetadata metadata,
                                                     boolean encrypted)
        throws OperationCancelledException {
        Log_OC.d(TAG, "Checking name collision in server");

        if (existsFile(client, mRemotePath, metadata, encrypted)) {
            switch (mNameCollisionPolicy) {
                case CANCEL:
                    Log_OC.d(TAG, "File exists; canceling");
                    throw new OperationCancelledException();
                case RENAME:
                    mRemotePath = getNewAvailableRemotePath(client, mRemotePath, metadata, encrypted);
                    mWasRenamed = true;
                    createNewOCFile(mRemotePath);
                    Log_OC.d(TAG, "File renamed as " + mRemotePath);
                    if (mRenameUploadListener != null) {
                        mRenameUploadListener.onRenameUpload();
                    }
                    break;
                case OVERWRITE:
                    Log_OC.d(TAG, "Overwriting file");
                    break;
                case ASK_USER:
                    Log_OC.d(TAG, "Name collision; asking the user what to do");
                    return new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
            }
        }

        if (mCancellationRequested.get()) {
            throw new OperationCancelledException();
        }

        return null;
    }

@tobiasKaminsky
Copy link
Member

Indeed, but is the upload then cancelled or just delayed?
Can you open up a PR for this? It would be great 👍

@b-pfl
Copy link

b-pfl commented Aug 17, 2021

I did experience the same situation, which probably affects every user who saves their images on an SD card when a) resetting App or phone or b) when switching to a new phone but keeping the old SD card.

So yes, in case of activating auto-upload and selecting the option to also include existing files, EVERY file should be checked and potentially uploaded.

Regarding the synchronization, I do have a few remarks/questions now: To properly sync files/images, I would have expected that
a) files that exist on the device but not on the server will just be uploaded (seems to work for new files, while it does not work for all existing files)
b) for files which exist on both sides, I would expect a proper check to happen:

  • in case the creation date, file size, and checksum are identical, a file will just be skipped (same file, has been uploaded successfully before)
  • only in case of a difference (any: date, size, or checksum) additional measures need to be taken (either through a pre-defined setting or explicit user interaction)

So I would expect a more thorough file checking (doesn't something similarr happen when using a normal sync on one of the desktop clients, too) to avoid tons of warnings, speed up the auto-upload process, and save bandwidth.

@b-pfl
Copy link

b-pfl commented Dec 3, 2021

@AlvaroBrey Will something like this be part of the new auto-upload feature? Would be great to have the same sync algorithm that the desktop client uses for syncing files. So if you switched phones / had to wipe your mobile device (but stored your images on an SD card), the auto upload feature check every file and just skip the exact same file that already exist on the server side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants