Skip to content

Conversation

@hsachdeva9
Copy link

Summary

  • Fix custom Windows folder icons being reset during sync operations
  • Preserve existing file attributes (especially FILE_ATTRIBUTE_SYSTEM) when updating CFAPI placeholders

Fixes #9197

Problem

On Windows, custom folder icons are implemented using:

  1. A desktop.ini file inside the folder
  2. The FILE_ATTRIBUTE_SYSTEM attribute set on the folder

When Nextcloud Desktop syncs folders, the CFAPI wrapper was resetting the FileAttributes field in CF_FS_METADATA to either FILE_ATTRIBUTE_NORMAL or FILE_ATTRIBUTE_DIRECTORY, causing the FILE_ATTRIBUTE_SYSTEM flag to be lost. This resulted in custom folder icons being reset to the default folder icon after every sync.

Solution

Before setting file attributes during CFAPI placeholder operations, the code now reads the current file attributes using GetFileAttributesW() and preserves them. This ensures that FILE_ATTRIBUTE_SYSTEM (and any other user-set attributes) are not lost during sync operations.

Changes made to src/libsync/vfs/cfapi/cfapiwrapper.cpp:

  1. updatePlaceholderState(): Added code to read and preserve existing file attributes before calling CfUpdatePlaceholder()

  2. createPlaceholderInfo(): Modified to check for existing file attributes before setting defaults

  3. createPlaceholdersInfo(): Same fix applied to the batch placeholder creation function

Test plan

  • Set a custom icon on a folder inside the Nextcloud sync directory (Right-click → Properties → Customize → Change Icon)
  • Add or modify a file inside that folder to trigger a sync
  • Verify the custom folder icon is preserved after sync completes
  • Repeat the test multiple times to ensure consistency

Signed-off-by: hsachdeva9 hiteshsachdeva343@gmail.com

@hsachdeva9 hsachdeva9 changed the title …er icons from being reset <!-- Thanks for opening a pull request on the Nextcloud desktop client. Instead of a Contributor License Agreement (CLA) we use a Developer Certificate of Origin (DCO). https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin To accept that DCO, please make sure that you add a line like Signed-off-by: Random Developer <random@developer.example.org> at the end of each commit message. This Signed-off-by trailer can be added automatically by git if you pass --signoff or -s to git commit. See also: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-signoff --> fix(vfs/cfapi): Preserve FILE_ATTRIBUTE_SYSTEM to prevent custom folder icons from being reset Dec 12, 2025
Copy link
Collaborator

@mgallien mgallien left a comment

Choose a reason for hiding this comment

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

@hsachdeva9
sounds fine but we will need an automated test to ensure this is working as intended (and not getting broken later)
could you add a test to enforce the new behavior (including also a test to ensure items without special attributes are not modified) ?

Copy link
Collaborator

@mgallien mgallien left a comment

Choose a reason for hiding this comment

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

did you use any specific tool to help you with the implementation ?
you will also need to ensure that the DCO check is not failing (https://github.com/nextcloud/desktop/pull/9235/checks)

@github-actions
Copy link

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

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.

[Bug]: Icon of a windows folder being reset at every sync

2 participants