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
Folders with custom icons not deletable on Windows #3744
Comments
So, "Read-only folders are read-only"? |
This surprises me as we have a test that verifies that we can remove read only directories in read only directories on Windows: https://github.com/syncthing/syncthing/blob/master/lib/osutil/osutil_test.go#L99 and we actually appear to be using that code to remove directories from the puller: https://github.com/syncthing/syncthing/blob/master/lib/model/rwfolder.go#L696 although not, for example, for removing stale tempfiles in it first so there is some inconsistency we should clean up... Is this generally reproducible by Windows folks? |
Maybe os.remove should be osutil.remove? |
We should replace it everywhere, yes. |
Oops. osutil.remove was removed back in August (18cc7a6) because Go had apparently fixed os.remove EDIT: Also, it looks like the test might be relying on an error occurring -- perhaps os.remove itself is failing silently. |
There's something else going on here beyond the read only bit. Read only directories can be deleted just fine. I tried to make a test for this, but if I create a read only folder, either from code or by creating it in Explorer and setting the read only bit: it deletes just fine by our normal procedure. But setting a custom icon does something else. Note the "1 file" supposedly in the directory now: That file isn't visible in cmd nor Explorer, but deleting the directory now indeed returns access denied. Maybe we manage to sync this custom icon anyway and this screws up the following delete. Needs someone who likes getting involved in Windows internals, which is not me beyond this point. :) |
I think there should be a folder.jpg that's not visible in there. |
Yeah I guess the only odd thing is the "access denied" vs the more reasonable "not empty" then. But this issue seems much more niche than I initially thought, and I'm leaving it for someone who cares more to figure out. :) |
Setting a custom icon will create a hidden |
Expanding on what @wweich said: Properties like custom icons get put into a file called Deletion of folders with this file in it works from the Windows file manager because it checks for this file and deletes it before deleting the folder if there is nothing else in the folder. Syncthing should probably do the same. |
@calmh Setting the attribute using the properties dialog only makes the files within the folder read-only. The folder itself is still just a regular folder. Creating a custom icon changes the attibute of the actual folder. Try using attrib from the command-line to create a "real" read-only folder. |
Actually, I couldn't delete the folder with custom icon in Windows Explorer until I remove the |
I tried os.RemoveAll, which deletes the desktop.ini, but the folder is still not deletable. |
Since nobody else seems to have submitted this as a Go issue yet: golang/go#26295 |
Sorry to bump this old unsolved issue, but ... It seems just plain wrong then to sync that attribute or its changes (from Windows only again)! |
We don't and that's not the problem here. I also suspect the standard library fix (linked from the issue above) misses the point as it just does a chmod of the directory before remove, which as far as I remember does not solve this problem with the custom icon. |
@calmh Now that Go 1.14 is out, I can confirm you are correct that the standard library fix does not solve the problem for Syncthing. But why not? I have an otherwise empty test folder with a custom icon package main
import (
"os"
)
func main() {
err := os.RemoveAll("C:/sync/test_folder_with_icon")
if err != nil {
panic(err)
}
} My Go knowledge is limited. What is the difference between what Syncthing does and what the short program above does? It seems to me that Syncthing uses |
We do Remove, not RemoveAll, as RemoveAll would delete ignored files, hence we rely on Remove to tell us that the directory is not empty and preventing us from deleting it. |
syncthing/lib/model/folder_sendrecv.go Line 1826 in 20aaa59
|
Hopefully it's not an issue to add details to a months old discussion, but I'm having a similar problem. I'm using Google Drive to sync my folder to a windows machine, and Syncthing to "bridge" the syncing to other workstations. Google drive puts custom icons on every folder synchronised, and I'm having frequent issues described by "Access is denied." The files and folders have "everyone" set to full control, so it's not a permission thing. Oddly if I delete the folders and restore them, they stop being a problem, but that has to be manual. I'm still researching this, but it appears to happen systematically with this setup:
Hope it could help reproducing what I think is a quite nasty bug. It doesn't seem to happen outside Drive, but I presume it's linked to the custom icons, when Drive isn't syncing the issue doesn't arise. I can confirm the problem is 100% reproducible on demand. |
I'm having this exact same issue. My mother has a desktop and a laptop she uses in her house. I use syncthings to sync files between the two machines locally. And then on the desktop I also backup the same folders to google drive. I am constantly getting this access denied error, I believe due to the google drive and custom icons it imposes. If I uninstall google drive then all of a sudden syncthings can do its job without issue. Has there been any fix to this problem? Any workaround? Please help. I want to have local sync + cloud backup both. |
I haven't tried but maybe an ignore pattern like |
As stated in Go repository : golang/go#26295 RemoveAll should be used instead of Remove for windows directories because Go returns an error in one case and not in the other when removing the same directory because of this issue with "custom" folders Also preventing with an ignore desktop.ini does not work. Example : syncthing/lib/model/folder_sendrecv.go Line 2039 in 452daad
Most of the tests I saw in the syncthing repo are done with RemoveAll instead of Remove but most of the code used in production uses Remove |
We should look at what RemoveAll does under the hood to handle this and adopt the relevant parts. (We want the remove to fail if there are unexpected items in the directory, as a safety measure, so we can't just start using RemoveAll everywhere.) |
I opened a pull request on Go repository to patch Remove : golang/go#56615 |
The "read only" part is a red herring, your chmod will do nothing to enable the removal of that directory. Removing desktop.ini should resolve it, but if I remember correctly the next level of problem is that the desktop.ini file isn't visible to us or isn't removable of a combination of the two. (If it were visible, the suggested |
If it really is a red herring as you think, you have to use RemoveAll as my first proposition to remove the desktop.ini and the folder |
* main: (36 commits) lib/protocol: Ignore inode time when xattr&ownership is ignored (fixes syncthing#8654) (syncthing#8655) lib/fs: Try to remove read only Windows files (fixes syncthing#3744) (syncthing#8650) gui: Add copy to clipboard, share by email, and share by SMS buttons to device IDs (fixes syncthing#2771, ref syncthing#3868) (syncthing#7984) gui, man, authors: Update docs, translations, and contributors build: Add GitHub actions build for Windows (syncthing#8627) gui: Fix connection type icon width (fixes syncthing#8592) (syncthing#8644) gui: Adjust connection type icon size scaling and alignment (syncthing#8645) docker: Use healthcheck endpoint (syncthing#8640) lib/connections: Use adaptive write size for rate limited connections (fixes syncthing#8630) (syncthing#8631) gui: Mark devices that haven't connected for a long time (fixes syncthing#7703) (syncthing#8530) gui: Fix rescan interval when add encrypted folder with watch for changes enabled (fixes syncthing#8570) (syncthing#8571) gui: Always show Out of Sync Items for remote devices (syncthing#8632) lib/fs: Let xattr test avoid non-test attributes (fixes syncthing#8601) (syncthing#8628) build: Add GitHub actions build for Windows gui, man, authors: Update docs, translations, and contributors gui: Display folder and device count number (syncthing#8615) gui, man, authors: Update docs, translations, and contributors lib/model, lib/protocol: Fix file comparisons (fixes syncthing#8594) (syncthing#8603) lib/scanner: More sensible debug output (syncthing#8596) gui: Allow automatic device ID selection on WebKit browsers (ref syncthing#8544) (syncthing#8597) ...
* main: (23 commits) lib/fs: Optimize WindowsInvalidFilename (syncthing#8687) gui, man, authors: Update docs, translations, and contributors cmd/syncthing: Use main logger in generate subcommand (fixes syncthing#8682) (syncthing#8685) build: Update all dependencies (fixes syncthing#8679) (syncthing#8680) gui, man, authors: Update docs, translations, and contributors lib/model: Correctly set xattrs on temp files (fixes syncthing#8667) (syncthing#8670) gui: Automatically dismiss authentication reminder when in LDAP mode (fixes syncthing#8661) (syncthing#8663) lib/model: Correctly handle xattrs on directories (fixes syncthing#8657) (syncthing#8658) lib/protocol: Ignore inode time when xattr&ownership is ignored (fixes syncthing#8654) (syncthing#8655) lib/fs: Try to remove read only Windows files (fixes syncthing#3744) (syncthing#8650) gui: Add copy to clipboard, share by email, and share by SMS buttons to device IDs (fixes syncthing#2771, ref syncthing#3868) (syncthing#7984) gui, man, authors: Update docs, translations, and contributors build: Add GitHub actions build for Windows (syncthing#8627) gui: Fix connection type icon width (fixes syncthing#8592) (syncthing#8644) gui: Adjust connection type icon size scaling and alignment (syncthing#8645) docker: Use healthcheck endpoint (syncthing#8640) lib/connections: Use adaptive write size for rate limited connections (fixes syncthing#8630) (syncthing#8631) gui: Mark devices that haven't connected for a long time (fixes syncthing#7703) (syncthing#8530) gui: Fix rescan interval when add encrypted folder with watch for changes enabled (fixes syncthing#8570) (syncthing#8571) gui: Always show Out of Sync Items for remote devices (syncthing#8632) ...
Hello, I've seen my code added to the repo but I've not been added to the Authors file |
The authorship script didn't pick up people who were only ever "co-authors" of a commit, such as when they wrote stuff which was later included in a PR by someone else, or added code during code review. This modified the script to look closer in the commit bodies for "Co-authored-by:"-lines and adds those found to the set of authors.
@AlexandreAlvesDB sorry about that, the script I was hoping to pick that up wasn't smart enough, I've fixed it in the PR above. |
No problem :) |
The authorship script didn't pick up people who were only ever "co-authors" of a commit, such as when they wrote stuff which was later included in a PR by someone else, or added code during code review. This modified the script to look closer in the commit bodies for "Co-authored-by:"-lines and adds those found to the set of authors.
* main: (69 commits) Handle relay connect timeout (fixes syncthing#8749) (syncthing#8755) gui, man, authors: Update docs, translations, and contributors build: Go 1.19.5 gui, man, authors: Update docs, translations, and contributors script: Add weblatedl.go for downloading updated translations (syncthing#8723) gui: Allow to translate action and type in Recent Changes modal (syncthing#8548) gui, man, authors: Update docs, translations, and contributors gui: Fix undefined lastSeenDays error in disconnected-inactive status check (ref syncthing#8530) (syncthing#8730) gui, man, authors: Update docs, translations, and contributors gui, api: Indicate running under container (syncthing#8728) lib/fs: Use io/fs errors as recommended in std lib (syncthing#8726) build: Handle co-authors (ref syncthing#3744) (syncthing#8708) lib/fs: Watching is unsupported on android/amd64 (fixes syncthing#8709) (syncthing#8710) lib/model: Only log at info level if setting change time fails (syncthing#8725) lib/model: Don't lower rescan interval from default on auto accepted enc folder (fixes syncthing#8572) (syncthing#8573) gui, man, authors: Update docs, translations, and contributors gui: Remove unmaintained language variant nl-BE (syncthing#8722) gui, script: Fix indentation in lang-en.json to match others (syncthing#8721) docker: Ensure entrypoint is executable (syncthing#8719) Go 1.19.4 ...
Syncing a folder with the read-only attribute set between Windows clients works as expected. However, when deleting the folder on one client, the other goes "Out of Sync" in the GUI with "access denied" in the Syncthing console.
The folder must then be manually deleted on the second machine (using explorer or "attrib" and "del" commands in the console.)
This seems similar to Issue #1610 only with folders rather than files.
Note: Windows sets the read-only attribute on folders automatically when you set a custom icon for said folder--that's how I initially discovered the issue. However, manually creating a read-only folder results in exactly the same behavior from Syncthing.
Syncthing Version: v0.14.11
OS Version: Windows 7
The text was updated successfully, but these errors were encountered: