syncthing / syncthing/syncthing

Incorrect local state when using `!` negated ignore patterns combined with parent folder ignored

Open
#8,735 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
88.8k
Forks
5.5k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

I believe this is likely responsible for the long-term issue I've been experiencing since basically forever which leads to non-matching local and remote folder states despite using the exact same ignore patterns on both sides.

  1. Share an empty folder between Device 1 (D1) and Device 2 (D2).
  2. Set the folder to "Send & Receive" on both sides.
  3. Add the following ignore patterns to the folder on both sides.
    !*.txt
    /
    
  4. The folders on both sides should now look as follows.
    image
    image
  5. Create the following hierarchy in the folder on D1.
    /folder
    /folder/file.txt
    
  6. Scan the folder on D1. Wait for the changes to sync to D2.
  7. The final state looks as follows.
    image
    image
  8. As you can see, the folder state on D1 is incorrect. Because file.txt is present inside /folder, the folder should be included in the local state as well, however in reality only the file is. Once this happens, neither rescanning the folder nor restarting Syncthing repairs the broken local state.

There is a caveat though. The steps above aren't complete. I've just managed to reproduce this in my test environment and I'm attaching logs with model,db enabled below, however in my testing I was repeatedly creating and removing folders and files in order to find the culprit. While doing so, I eventually managed to reach the state as seen above, but I can't reproduce it at will directly yet.

The logs should contain the relevant information though. They aren't very large either, as the whole testing took less than 10 minutes or so.

syncthing1.log
syncthing2.log

For the record, I think the actual synchronisation still functions fine despite the incorrect local states. However, I've encountered problems with Receive Only folders being stuck in a permanent "Out of Sync" state which I believe is likely related to this very bug. I still haven't been able to reproduce that one in my test environment though.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the listed two-device scenario with the !*.txt and / ignore patterns, then inspect the model,db entries in syncthing1.log and syncthing2.log. Focus on how the ignored parent folder and included file update local state after synchronization. Done means the parent folder is included in the local state when it contains the synchronized file.txt, and rescanning or restarting is not needed to repair it.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.