You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Folders with custom icons not deletable on Windows #3744
bugA problem with current functionality, as opposed to missing functionality (enhancement)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
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.
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. :)
changed the title [-]lib/osutil: Read-only folders not deletable on Windows[/-][+]Folders with custom icons not deletable on Windows[/+]on Mar 24, 2017
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 desktop.ini file. You can see it with dir /a or by unchecking "hide system files" in the Windows Explorer settings.
Deleting that file will unlock the folder.
Expanding on what @wweich said: Properties like custom icons get put into a file called desktop.ini that has the 'system' attribute bit set, which means that it is hidden unless you have the 'Hide Protected Operating System Files' option disabled in your Folder Settings. The file itself is essentially equivalent to an OS X resource fork for a directory. It originated back when Windows still used FAT as the default filesystem (and thus didn't have alternative data streams to stuff the data in), and has stuck around because Microsoft are too lazy and obsessed with making ancient software continue working to update it to do things right.
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.
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 (?d)desktop.ini pattern would work, because that means "delete that file before deleting the directory".)
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
If the bug was still open, it was for a reason, you have probably not read the thread but even without desktop.ini, os.Remove in Golang doesn't work for folder who had an icon, that's why I proposed the patch
bugA problem with current functionality, as opposed to missing functionality (enhancement)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Activity
canton7 commentedon Nov 19, 2016
So, "Read-only folders are read-only"?
calmh commentedon Nov 19, 2016
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?
meztup commentedon Nov 19, 2016
Maybe os.remove should be osutil.remove?
AudriusButkevicius commentedon Nov 19, 2016
We should replace it everywhere, yes.
meztup commentedon Nov 19, 2016
Oops.
osutil.remove was removed back in August (18cc7a6) because Go had apparently fixed os.remove
EDIT:
I just went back and tested Syncthing v0.14.4 from August 10th (release prior to the above changes) and it worked perfectly.
Also, it looks like the test might be relying on an error occurring -- perhaps os.remove itself is failing silently.
[-]Read-only folders not deletable on Windows[/-][+]lib/osutil: Read-only folders not deletable on Windows[/+]calmh commentedon Mar 24, 2017
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. :)
[-]lib/osutil: Read-only folders not deletable on Windows[/-][+]Folders with custom icons not deletable on Windows[/+]AudriusButkevicius commentedon Mar 24, 2017
I think there should be a folder.jpg that's not visible in there.
calmh commentedon Mar 24, 2017
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. :)
wweich commentedon Mar 24, 2017
Setting a custom icon will create a hidden
desktop.inifile. You can see it withdir /aor by unchecking "hide system files" in the Windows Explorer settings.Deleting that file will unlock the folder.
Ferroin commentedon Mar 24, 2017
Expanding on what @wweich said: Properties like custom icons get put into a file called
desktop.inithat has the 'system' attribute bit set, which means that it is hidden unless you have the 'Hide Protected Operating System Files' option disabled in your Folder Settings. The file itself is essentially equivalent to an OS X resource fork for a directory. It originated back when Windows still used FAT as the default filesystem (and thus didn't have alternative data streams to stuff the data in), and has stuck around because Microsoft are too lazy and obsessed with making ancient software continue working to update it to do things right.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.
meztup commentedon Mar 24, 2017
@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.
15 remaining items
calmh commentedon Nov 6, 2022
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
(?d)desktop.inipattern would work, because that means "delete that file before deleting the directory".)AlexandreAlvesDB commentedon Nov 6, 2022
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
If the bug was still open, it was for a reason, you have probably not read the thread but even without desktop.ini, os.Remove in Golang doesn't work for folder who had an icon, that's why I proposed the patch
Merge branch 'main' into fix-8556
Merge branch 'main' into linuxbuild
AlexandreAlvesDB commentedon Dec 7, 2022
Hello, I've seen my code added to the repo but I've not been added to the Authors file
build: Handle co-authors (ref syncthing#3744)
calmh commentedon Dec 7, 2022
@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.
AlexandreAlvesDB commentedon Dec 7, 2022
No problem :)
build: Handle co-authors (ref #3744) (#8708)
Merge branch 'main' into dockerpool
lib/fs: Try to remove read only Windows files (fixes syncthing#3744) (s…