Skip to content

fix: sync engine readonly folder file deletion - #10226

Merged
mgallien merged 3 commits into
nextcloud:masterfrom
guruz:master_fix_7797
Sep 15, 2026
Merged

mgallien merged 3 commits into
nextcloud:masterfrom
guruz:master_fix_7797

Conversation

@guruz

@guruz guruz commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Resolves

This is for #7797 and #10099

It would probably be good to backport this (if it's the correct fix and is merged...)

Summary

Show stray file in UI instead of agressively deleting it (= potential data loss)

Screenshot 2026-06-22 at 11 01 05

Checklist

AI (if applicable)

@guruz

guruz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

I'll look at the test failure..

@guruz
guruz force-pushed the master_fix_7797 branch 2 times, most recently from b3836a7 to 18bfc50 Compare June 25, 2026 11:19
@guruz

guruz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

I've made the code distinct between totally new file and move of existing file from same sync folder to the readonly dir.
In the latter case, the file will be deleted and restored at original location.
(EDIT: Also added explicit test for this restore case into PermissionsTest)

I've also enabled the PermissionsTest on MacOS since they now all pass on my machine. Let's see if the CI sees it differently?

(I also rebased on master)

@guruz
guruz force-pushed the master_fix_7797 branch from 18bfc50 to d050909 Compare June 25, 2026 11:33
@github-actions

Copy link
Copy Markdown
Contributor

Artifact containing the AppImage: nextcloud-appimage-pr-10226.zip

Digest: sha256:d09f4f55cf3c4bf7aade303b1b0cc26ccd4b5099f2e1e011ce8ace6796b0e4e5

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

@mid1221213

Copy link
Copy Markdown

Tested OK on my setup (binary built on commit a910031 on a Debian unstable and using a kinda "custom" NC server): the Desktop Client patched with the content of this MR behaves exactly as told.

@guruz

guruz commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

CI failure seems unrelated:
15:22:48.566 ERROR Not authorized or project not found. Please check the 'SONAR_TOKEN' environment variable, the 'sonar.projectKey' and 'sonar.organization' properties, or contact the project administrator to verify the token's permissions.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@mgallien mgallien left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sorry for the delay
a few questions or request for changes

Comment thread src/libsync/discovery.cpp
Comment on lines +2028 to +2029
// Do NOT schedule the new local folder for deletion: it may contain data the user just
// created and that exists nowhere else. (see read-only folder regression, issues #7797/#10099).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should not this folder be read-only ?
I guess users can override the permissions and better be safe than sorry

Comment thread src/libsync/discovery.cpp
Comment on lines +2035 to +2036
// Do NOT schedule the new local file for deletion: it may be data the user just created
// and that exists nowhere else. (see read-only folder regression, issues #7797/#10099).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same question (unless I miss something)

Comment thread test/testpermissions.cpp Outdated
@mgallien

Copy link
Copy Markdown
Collaborator

@guruz gentle reminder

@guruz

guruz commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@guruz gentle reminder

Sorry, on vacation now still, I'll have a look at your comments a bit later..

Regarding the code comments: It's about the read-only folder where users put files/folders in. Not about the new file/folder they put in.
(Server side read only shared with user..)

(users are locally are still able to put files into it, the read-only permissions can be overriden by the OS/file manager/user etc.. so we want to rescue thos files to be accidently deleted)

@mid1221213

mid1221213 commented Jul 26, 2026

Copy link
Copy Markdown

If I may…

IMO this MR is a (good) workaround to the bug (or lack of feature?) that if a directory has the permission flag "read-only" set, nothing prevents people to write in the directory client-side, or delete something, etc…

To me the client should just do a chmod -w on it, as I think (IIRC) it was the case before.

IIRC (again, but I may be wrong) it was the fact that Windows does not support chmod operations that led to its removal. I think that it would be better to use a workaround (like this one) for Windows, or at least issue a warning, and do the chmod on other OSes (i.e. all others) that support it.

And it may be the very same reason that symlinks are not supported, too, IIRC again. Even if this one (symlinks) seems to be off topic here, that's also too bad and share, actually, the same origin, i.e. Windows support limiting features on other platforms.

@guruz

guruz commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, on vacation now still, I'll have a look at your comments a bit later..

I'm back and will look at this this week @mgallien

To me the client should just do a chmod -w on it, as I think (IIRC) it was the case before.

It does for me on MacOS, but this can be easily acciently circumvented for example by pressing the right button in Finder copy dialog :-)

guruz@Mac ADirectory $ ls -ld .
dr-xr-xr-x@ 4 guruz  staff   128B Aug 2 13:25 .

@guruz

guruz commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

but this can be easily acciently circumvented for example by pressing the right button in Finder copy dialog

Or by doing sudo or being a root user. The directory is (without this patch) a black hole for new client sides files dropped into it.

(Other OS might be different/better/worse)

This is for nextcloud#7797 and nextcloud#10099

Signed-off-by: Markus Goetz <markus@woboq.com>
Assisted-by: ClaudeCode:claude-opus-4-8
@guruz
guruz force-pushed the master_fix_7797 branch from d050909 to 0f1baf1 Compare August 3, 2026 11:19
@guruz
guruz requested a review from claucambra as a code owner August 3, 2026 11:19
@guruz
guruz requested a review from mgallien August 3, 2026 11:20
@guruz

guruz commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi, Any news on this one? :)

@danimo

danimo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Hey! Is there anything that still needs doing for this to be merged?

@claucambra claucambra added this to the 34.0.4 milestone Sep 9, 2026
@mgallien

Copy link
Copy Markdown
Collaborator

@guruz sorry for the delay
can you rebase to solve the conflicts ?
it should them merge by itself

@mgallien

Copy link
Copy Markdown
Collaborator

/backport to stable-34.0 please

@mgallien

Copy link
Copy Markdown
Collaborator

Sorry, on vacation now still, I'll have a look at your comments a bit later..

I'm back and will look at this this week @mgallien

To me the client should just do a chmod -w on it, as I think (IIRC) it was the case before.

It does for me on MacOS, but this can be easily acciently circumvented for example by pressing the right button in Finder copy dialog :-)

guruz@Mac ADirectory $ ls -ld .
dr-xr-xr-x@ 4 guruz  staff   128B Aug 2 13:25 .

I get it now
even if I now that you can work around the permissions, I was unaware that Finder makes it easy

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
@mgallien mgallien modified the milestones: 34.0.4, 34.0.5 Sep 15, 2026
@mgallien

Copy link
Copy Markdown
Collaborator

@guruz we enabled compilation of the desktop client with Qt keywords only in upper case form
code is not compiling currently and we do a release today
we are still looking forward to merge this PR
can you help 🙏

auto-merge was automatically disabled September 15, 2026 08:00

Head branch was pushed to by a user without write access

@guruz

guruz commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

OK, i pushed a possible fix, let's see the CI?

can you rebase to solve the conflicts ?

Sorry, I had not seen this message...

@mgallien

Copy link
Copy Markdown
Collaborator

OK, i pushed a possible fix, let's see the CI?

Thanks
can you fix the missing DCO information on the latest commit 🙏

I enabled the CI to check compilation despite this but we need the DCO to merge the PR

can you rebase to solve the conflicts ?

Sorry, I had not seen this message...

Signed-off-by: Markus Goetz <markus@woboq.com>
@mgallien
mgallien enabled auto-merge September 15, 2026 14:58
@mgallien
mgallien merged commit cde3965 into nextcloud:master Sep 15, 2026
18 of 20 checks passed
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.

5 participants