Windows | Syncthing v1.29.7 file watcher keeps handle open

Hi,

I’ve maybe discovered a bug. I’ve got a windows drive that can be locked and unlocked. To reproduce, you could e.g. use Bitlocker and create an encrypted drive with a password “testtest”. Let’s call the drive A:.

  1. Use Bitlocker to create the A: drive, format NTFS, specify an unlock password, turn off “auto unlock on boot”.
  2. Setup Syncthing folder on it: A:\sync ; fileWatcher = enabled ; rescanInterval = 15m
  3. Let some files sync to it, wait for Syncthing to be “idle”.
  4. Lock the drive using: manage-bde -lock A:
  5. (Locking fails, drive is in use error) I expect that the drive locks instead.

Workaround: In step 2. set fileWatcher = disabled ; rescanInterval = 2m

→ Locking still fails in step 4.

Restart “Syncthing.exe”

→ Locking succeeds in step 4. Even if I have it sync more files after unlock and stay up for a day on this machine.

What I suspect as a bug: Syncthing doesn’t clear the handle to the A: drive’s filesystem when “fileWatcher = enabled” is changed to “fileWatcher = disabled”, thus I require manual restart of “syncthing.exe”. The “leaked handle” to the A: drive can be confirmed by Process Explorer (by Sysinternals).

Thanks for looking into it :slight_smile: .