Skip to content

Folders with custom icons not deletable on Windows #3744

Closed

Description

@meztup

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

Activity

  1. canton7 commented on Nov 19, 2016

    @canton7
    Contributor

    So, "Read-only folders are read-only"?

  2. added
    bug
    on Nov 19, 2016
  3. added this to the milestone on Nov 19, 2016
  4. calmh commented on Nov 19, 2016

    @calmh
    Member

    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?

  5. meztup commented on Nov 19, 2016

    @meztup
    Author

    Maybe os.remove should be osutil.remove?

  6. AudriusButkevicius commented on Nov 19, 2016

    @AudriusButkevicius
    Member

    We should replace it everywhere, yes.

  7. meztup commented on Nov 19, 2016

    @meztup
    Author

    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.

  8. changed the title [-]Read-only folders not deletable on Windows[/-] [+]lib/osutil: Read-only folders not deletable on Windows[/+] on Nov 23, 2016
  9. calmh commented on Mar 24, 2017

    @calmh
    Member

    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:

    screen shot 2017-03-23 at 21 08 39

    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:

    screen shot 2017-03-23 at 21 07 32

    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. :)

  10. changed the title [-]lib/osutil: Read-only folders not deletable on Windows[/-] [+]Folders with custom icons not deletable on Windows[/+] on Mar 24, 2017
  11. AudriusButkevicius commented on Mar 24, 2017

    @AudriusButkevicius
    Member

    I think there should be a folder.jpg that's not visible in there.

  12. calmh commented on Mar 24, 2017

    @calmh
    Member

    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. :)

  13. wweich commented on Mar 24, 2017

    @wweich
    Contributor

    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.

  14. Ferroin commented on Mar 24, 2017

    @Ferroin

    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.

  15. meztup commented on Mar 24, 2017

    @meztup
    Author

    @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.

  16. 15 remaining items

  17. calmh commented on Nov 6, 2022

    @calmh
    Member

    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".)

  18. AlexandreAlvesDB commented on Nov 6, 2022

    @AlexandreAlvesDB
    Contributor

    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

  19. added a commit that references this issue on Nov 8, 2022
    db49472
  20. added this to the v1.22.2 milestone on Nov 9, 2022
  21. added a commit that references this issue on Nov 22, 2022
    4ee1015
  22. AlexandreAlvesDB commented on Dec 7, 2022

    @AlexandreAlvesDB
    Contributor

    Hello, I've seen my code added to the repo but I've not been added to the Authors file

  23. calmh commented on Dec 7, 2022

    @calmh
    Member

    @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.

  24. AlexandreAlvesDB commented on Dec 7, 2022

    @AlexandreAlvesDB
    Contributor

    @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 :)

  25. added a commit that references this issue on Dec 21, 2022
  26. added a commit that references this issue on Jan 23, 2023
  27. added
    frozen-due-to-age
    on Nov 8, 2023
  28. locked and limited conversation to collaborators on Nov 8, 2023
  29. added a commit that references this issue on Jan 30, 2024
    a296057
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions