Repository: syncthing/syncthing (language: go)

Issue:
junctionsAsDirs requires folder pause and resume to trigger
This is very similar to the fixed https://github.com/syncthing/syncthing/issues/7371. Follow the same steps to reproduce.

The problem now is that ticking the option in the Advanced Configuration does not affect the folder until we pause and resume it. The configuration is not applied automatically, and rescanning also does nothing.

Would it be possible to make the option work immediately upon saving the changes in the Advanced Configuration (perhaps simply by forcing a pause/resume cycle if no clean application is possible)?
junctionsAsDirs requires folder pause and resume to trigger
This is very similar to the fixed https://github.com/syncthing/syncthing/issues/7371. Follow the same steps to reproduce.

The problem now is that ticking the option in the Advanced Configuration does not affect the folder until we pause and resume it. The configuration is not applied automatically, and rescanning also does nothing.

Would it be possible to make the option work immediately upon saving the changes in the Advanced Configuration (perhaps simply by forcing a pause/resume cycle if no clean application is possible)?


Discussion / hints:
Are you certain this still happens since https://github.com/syncthing/syncthing/commit/aa1c2742314b1d1a6edb0453ca5f1b1d957db631? Any folder config change except label triggers a folder restart.
Yeah, I am certain. I've just done another test. The junction wasn't detected until I manually paused and resumed the folder.

I guess this requires a Windows system to test, so if I can help with any special debug logs, please let me know.
model debug log that shows the sequence of events (config change, scan, pause-resume, scan) would be a good start
Here you go.

```
[start] 2022/01/29 17:48:23.251046 main.go:530: INFO: syncthing v1.19.0-rc.2.dev.5.g73e2e2a7 "Fermium Flea" (go1.17.6 windows-amd64) tomasz86@tomasz86 2022-01-28 08:15:56 UTC [noupgrade, stnoupgrade]
[DHK2G] 2022/01/29 17:48:23.261446 syncthing.go:154: INFO: My ID: DHK2GDE-HKTNORH-WX4U2BV-CSZ7LPY-66HMKLW-RQ4RJF4-V4OTKHL-AAN7GQF
[DHK2G] 2022/01/29 17:48:24.164960 sha256.go:88: INFO: Single thread SHA256 performance is 1920 MB/s using minio/sha256-simd (471 MB/s using crypto/sha256).
[DHK2G] 2022/01/29 17:48:24.619934 syncthing.go:186: INFO: Hashing performance is 1119.92 MB/s
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 1...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 2...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 3...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 5...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 6...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 7...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 9...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 10...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 11...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 13...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 14...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 16...
[DHK2G] 2022/01/29 17:48:24.620935 schemaupdater.go:110: INFO: Running database migration 17...
[DHK2G] 2022/01/29 17:48:24.620935 schemaupdater.go:110: INFO: Running database migration 19...
[DHK2G] 2022/01/29 17:48:24.620935 schemaupdater.go:128: INFO: Compacting database after migration...
[DHK2G] 2022/01/29 17:48:24.623938 progressemitter.go:228: DEBUG: progress emitter: updated interval 5s
[DHK2G] 2022/01/29 17:48:24.624936 model.go:329: INFO: Starting deadlock detector with 20m0s timeout
[DHK2G] 2022/01/29 17:48:24.624936 limiter.go:163: INFO: Overall send rate is unlimited, receive rate is unlimited
[DHK2G] 2022/01/29 17:48:24.624936 syncthing.go:290: INFO: Anonymous usage reporting is always enabled for candidate releases.
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: global discovery server https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[DHK2G] 2022/01/29 17:48:24.624936 relay_listen.go:57: INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: global discovery server https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: global discovery server https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: IPv4 local broadcast discovery on port 21027
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: IPv6 local multicast discovery on address [ff12::8384]:21027
[DHK2G] 2022/01/29 17:48:24.625937 progressemitter.go:79: DEBUG: progress emitter: timer - looking after 0
[DHK2G] 2022/01/29 17:48:24.625937 progressemitter.go:98: DEBUG: progress emitter: nothing new
[DHK2G] 2022/01/29 17:48:24.630938 tcp_listen.go:75: INFO: TCP listener ([::]:51355) starting
[DHK2G] 2022/01/29 17:48:24.630938 quic_listen.go:116: INFO: QUIC listener ([::]:51355) starting
[DHK2G] 2022/01/29 17:48:24.631938 api.go:388: INFO: GUI and API listening on 127.0.0.1:8391
[DHK2G] 2022/01/29 17:48:24.631938 api.go:389: INFO: Access the GUI via the following URL: http://localhost:8391/
[DHK2G] 2022/01/29 17:48:24.631938 syncthing.go:314: INFO: My name is "syncthing1"
[DHK2G] 2022/01/29 17:48:24.631938 syncthing.go:317: INFO: Device IDWWV34-CPCARWX-WXGQCSZ-QRWRJIK-NLKUR3I-FJHAKYN-OUINC3B-QW3XJAW is "syncthing2" at [dynamic]
[DHK2G] 2022/01/29 17:48:24.631938 syncthing.go:317: INFO: Device NQ6TOQB-PJYJRYB-GBYMPBG-YCX6L2B-GEQX7RG-M5WT3UL-BXPUYOL-TJJZAA6 is "syncthing3" at [dynamic]
[DHK2G] 2022/01/29 17:48:34.769706 structs.go:30: INFO: New NAT port mapping: external TCP address 192.168.1.2:49371 to local address [::]:51355.
[DHK2G] 2022/01/29 17:48:34.771708 service.go:103: INFO: Detected 1 NAT service
[DHK2G] 2022/01/29 17:48:37.646026 model.go:2801: INFO: Adding folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:48:37.646026 lowlevel.go:1031: INFO: No stored folder metadata for "cg9bu-eiaml"; recalculating
[DHK2G] 2022/01/29 17:48:37.647027 model.go:424: INFO: Ready to synchronize "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:48:37.647027 folder.go:146: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 starting
[DHK2G] 2022/01/29 17:48:37.651028 folder.go:197: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 Scanning due to timer
[DHK2G] 2022/01/29 17:48:37.651028 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 scanning
[DHK2G] 2022/01/29 17:48:37.651028 folder.go:1004: DEBUG: Started filesystem watcher for folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:48:37.652028 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:48:37.652028 folder.go:904: INFO: Completed initial scan of sendreceive folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:48:37.652028 folder.go:305: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 next rescan in 52m49.169998737s
[DHK2G] 2022/01/29 17:48:37.679034 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:48:38.731225 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:48:42.658264 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:48:44.791236 quic_listen.go:56: INFO: quic://0.0.0.0:51355 detected NAT type: Port restricted NAT
[DHK2G] 2022/01/29 17:48:44.791236 quic_listen.go:75: INFO: quic://0.0.0.0:51355 resolved external address quic://95.49.225.169:51355 (via stun.syncthing.net:3478)
[DHK2G] 2022/01/29 17:49:09.671274 static.go:65: INFO: Joined relay relay://37.187.57.69:22067
[DHK2G] 2022/01/29 17:49:14.281924 folder.go:214: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 Scan due to watcher
[DHK2G] 2022/01/29 17:49:14.281924 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 scanning
[DHK2G] 2022/01/29 17:49:14.282985 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:49:21.505645 folder.go:175: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 exiting
[DHK2G] 2022/01/29 17:49:21.506154 model.go:424: INFO: Ready to synchronize "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:21.506154 model.go:581: INFO: Restarted folder "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:21.506154 folder.go:146: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 starting
[DHK2G] 2022/01/29 17:49:21.508753 folder.go:197: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 Scanning due to timer
[DHK2G] 2022/01/29 17:49:21.508753 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 scanning
[DHK2G] 2022/01/29 17:49:21.509278 folder.go:1004: DEBUG: Started filesystem watcher for folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:21.509799 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:49:21.509799 folder.go:904: INFO: Completed initial scan of sendreceive folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:21.509799 folder.go:305: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 next rescan in 58m58.580368797s
[DHK2G] 2022/01/29 17:49:21.522641 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:22.582685 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:26.523122 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:29.801749 folder.go:201: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 Running something due to request
[DHK2G] 2022/01/29 17:49:29.801749 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 scanning
[DHK2G] 2022/01/29 17:49:29.802296 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:49:32.560649 folder.go:175: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 exiting
[DHK2G] 2022/01/29 17:49:32.560649 model.go:581: INFO: Paused folder "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:34.491133 model.go:424: INFO: Ready to synchronize "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:34.491133 folder.go:146: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 starting
[DHK2G] 2022/01/29 17:49:34.491133 model.go:581: INFO: Unpaused folder "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:34.494818 folder.go:197: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 Scanning due to timer
[DHK2G] 2022/01/29 17:49:34.494818 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 scanning
[DHK2G] 2022/01/29 17:49:34.495922 folder.go:1004: DEBUG: Started filesystem watcher for folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:34.498622 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 finished scanning, detected 2 changes
[DHK2G] 2022/01/29 17:49:34.498622 folder.go:904: INFO: Completed initial scan of sendreceive folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:34.498622 folder.go:305: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 next rescan in 1h0m36.292669561s
[DHK2G] 2022/01/29 17:49:34.530546 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:34.900432 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:35.537527 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:37.580714 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:39.564282 folder.go:175: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 exiting
[DHK2G] 2022/01/29 17:49:39.564282 quic_listen.go:140: INFO: QUIC listener ([::]:51355) shutting down
[DHK2G] 2022/01/29 17:49:39.564798 progressemitter.go:75: DEBUG: progress emitter: stopping
[DHK2G] 2022/01/29 17:49:39.564805 relay_listen.go:65: INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) shutting down
[DHK2G] 2022/01/29 17:49:40.257533 tcp_listen.go:110: INFO: TCP listener ([::]:51355) shutting down
[DHK2G] 2022/01/29 17:49:40.258058 syncthing.go:353: INFO: Exiting
```

I did the following.

1. Add a new, empty folder to Syncthing.
2. In the folder, create a junction using the command line.
3. Enable `junctionsAsDir` for the folder.
4. Click the "rescan" button, but with no success.
5. Pause and resume the folder.
6. Only now has the junction been detected.
Ah yes, I only thought about the folder config and it's `.Filesystem`. However there's also the `FileSet` with its `.MtimeFS`. Thanks!
Are you certain this still happens since https://github.com/syncthing/syncthing/commit/aa1c2742314b1d1a6edb0453ca5f1b1d957db631? Any folder config change except label triggers a folder restart.
Yeah, I am certain. I've just done another test. The junction wasn't detected until I manually paused and resumed the folder.

I guess this requires a Windows system to test, so if I can help with any special debug logs, please let me know.
model debug log that shows the sequence of events (config change, scan, pause-resume, scan) would be a good start
Here you go.

```
[start] 2022/01/29 17:48:23.251046 main.go:530: INFO: syncthing v1.19.0-rc.2.dev.5.g73e2e2a7 "Fermium Flea" (go1.17.6 windows-amd64) tomasz86@tomasz86 2022-01-28 08:15:56 UTC [noupgrade, stnoupgrade]
[DHK2G] 2022/01/29 17:48:23.261446 syncthing.go:154: INFO: My ID: DHK2GDE-HKTNORH-WX4U2BV-CSZ7LPY-66HMKLW-RQ4RJF4-V4OTKHL-AAN7GQF
[DHK2G] 2022/01/29 17:48:24.164960 sha256.go:88: INFO: Single thread SHA256 performance is 1920 MB/s using minio/sha256-simd (471 MB/s using crypto/sha256).
[DHK2G] 2022/01/29 17:48:24.619934 syncthing.go:186: INFO: Hashing performance is 1119.92 MB/s
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 1...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 2...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 3...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 5...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 6...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 7...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 9...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 10...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 11...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 13...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 14...
[DHK2G] 2022/01/29 17:48:24.619934 schemaupdater.go:110: INFO: Running database migration 16...
[DHK2G] 2022/01/29 17:48:24.620935 schemaupdater.go:110: INFO: Running database migration 17...
[DHK2G] 2022/01/29 17:48:24.620935 schemaupdater.go:110: INFO: Running database migration 19...
[DHK2G] 2022/01/29 17:48:24.620935 schemaupdater.go:128: INFO: Compacting database after migration...
[DHK2G] 2022/01/29 17:48:24.623938 progressemitter.go:228: DEBUG: progress emitter: updated interval 5s
[DHK2G] 2022/01/29 17:48:24.624936 model.go:329: INFO: Starting deadlock detector with 20m0s timeout
[DHK2G] 2022/01/29 17:48:24.624936 limiter.go:163: INFO: Overall send rate is unlimited, receive rate is unlimited
[DHK2G] 2022/01/29 17:48:24.624936 syncthing.go:290: INFO: Anonymous usage reporting is always enabled for candidate releases.
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: global discovery server https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[DHK2G] 2022/01/29 17:48:24.624936 relay_listen.go:57: INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: global discovery server https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: global discovery server https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: IPv4 local broadcast discovery on port 21027
[DHK2G] 2022/01/29 17:48:24.624936 manager.go:89: INFO: Using discovery mechanism: IPv6 local multicast discovery on address [ff12::8384]:21027
[DHK2G] 2022/01/29 17:48:24.625937 progressemitter.go:79: DEBUG: progress emitter: timer - looking after 0
[DHK2G] 2022/01/29 17:48:24.625937 progressemitter.go:98: DEBUG: progress emitter: nothing new
[DHK2G] 2022/01/29 17:48:24.630938 tcp_listen.go:75: INFO: TCP listener ([::]:51355) starting
[DHK2G] 2022/01/29 17:48:24.630938 quic_listen.go:116: INFO: QUIC listener ([::]:51355) starting
[DHK2G] 2022/01/29 17:48:24.631938 api.go:388: INFO: GUI and API listening on 127.0.0.1:8391
[DHK2G] 2022/01/29 17:48:24.631938 api.go:389: INFO: Access the GUI via the following URL: http://localhost:8391/
[DHK2G] 2022/01/29 17:48:24.631938 syncthing.go:314: INFO: My name is "syncthing1"
[DHK2G] 2022/01/29 17:48:24.631938 syncthing.go:317: INFO: Device IDWWV34-CPCARWX-WXGQCSZ-QRWRJIK-NLKUR3I-FJHAKYN-OUINC3B-QW3XJAW is "syncthing2" at [dynamic]
[DHK2G] 2022/01/29 17:48:24.631938 syncthing.go:317: INFO: Device NQ6TOQB-PJYJRYB-GBYMPBG-YCX6L2B-GEQX7RG-M5WT3UL-BXPUYOL-TJJZAA6 is "syncthing3" at [dynamic]
[DHK2G] 2022/01/29 17:48:34.769706 structs.go:30: INFO: New NAT port mapping: external TCP address 192.168.1.2:49371 to local address [::]:51355.
[DHK2G] 2022/01/29 17:48:34.771708 service.go:103: INFO: Detected 1 NAT service
[DHK2G] 2022/01/29 17:48:37.646026 model.go:2801: INFO: Adding folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:48:37.646026 lowlevel.go:1031: INFO: No stored folder metadata for "cg9bu-eiaml"; recalculating
[DHK2G] 2022/01/29 17:48:37.647027 model.go:424: INFO: Ready to synchronize "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:48:37.647027 folder.go:146: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 starting
[DHK2G] 2022/01/29 17:48:37.651028 folder.go:197: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 Scanning due to timer
[DHK2G] 2022/01/29 17:48:37.651028 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 scanning
[DHK2G] 2022/01/29 17:48:37.651028 folder.go:1004: DEBUG: Started filesystem watcher for folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:48:37.652028 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:48:37.652028 folder.go:904: INFO: Completed initial scan of sendreceive folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:48:37.652028 folder.go:305: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 next rescan in 52m49.169998737s
[DHK2G] 2022/01/29 17:48:37.679034 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:48:38.731225 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:48:42.658264 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:48:44.791236 quic_listen.go:56: INFO: quic://0.0.0.0:51355 detected NAT type: Port restricted NAT
[DHK2G] 2022/01/29 17:48:44.791236 quic_listen.go:75: INFO: quic://0.0.0.0:51355 resolved external address quic://95.49.225.169:51355 (via stun.syncthing.net:3478)
[DHK2G] 2022/01/29 17:49:09.671274 static.go:65: INFO: Joined relay relay://37.187.57.69:22067
[DHK2G] 2022/01/29 17:49:14.281924 folder.go:214: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 Scan due to watcher
[DHK2G] 2022/01/29 17:49:14.281924 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 scanning
[DHK2G] 2022/01/29 17:49:14.282985 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:49:21.505645 folder.go:175: DEBUG: sendreceive/cg9bu-eiaml@0xc0005f3180 exiting
[DHK2G] 2022/01/29 17:49:21.506154 model.go:424: INFO: Ready to synchronize "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:21.506154 model.go:581: INFO: Restarted folder "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:21.506154 folder.go:146: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 starting
[DHK2G] 2022/01/29 17:49:21.508753 folder.go:197: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 Scanning due to timer
[DHK2G] 2022/01/29 17:49:21.508753 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 scanning
[DHK2G] 2022/01/29 17:49:21.509278 folder.go:1004: DEBUG: Started filesystem watcher for folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:21.509799 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:49:21.509799 folder.go:904: INFO: Completed initial scan of sendreceive folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:21.509799 folder.go:305: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 next rescan in 58m58.580368797s
[DHK2G] 2022/01/29 17:49:21.522641 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:22.582685 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:26.523122 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:29.801749 folder.go:201: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 Running something due to request
[DHK2G] 2022/01/29 17:49:29.801749 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 scanning
[DHK2G] 2022/01/29 17:49:29.802296 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 finished scanning, detected 0 changes
[DHK2G] 2022/01/29 17:49:32.560649 folder.go:175: DEBUG: sendreceive/cg9bu-eiaml@0xc000183c00 exiting
[DHK2G] 2022/01/29 17:49:32.560649 model.go:581: INFO: Paused folder "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:34.491133 model.go:424: INFO: Ready to synchronize "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:34.491133 folder.go:146: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 starting
[DHK2G] 2022/01/29 17:49:34.491133 model.go:581: INFO: Unpaused folder "test1" (cg9bu-eiaml) (sendreceive)
[DHK2G] 2022/01/29 17:49:34.494818 folder.go:197: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 Scanning due to timer
[DHK2G] 2022/01/29 17:49:34.494818 folder.go:428: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 scanning
[DHK2G] 2022/01/29 17:49:34.495922 folder.go:1004: DEBUG: Started filesystem watcher for folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:34.498622 folder.go:496: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 finished scanning, detected 2 changes
[DHK2G] 2022/01/29 17:49:34.498622 folder.go:904: INFO: Completed initial scan of sendreceive folder "test1" (cg9bu-eiaml)
[DHK2G] 2022/01/29 17:49:34.498622 folder.go:305: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 next rescan in 1h0m36.292669561s
[DHK2G] 2022/01/29 17:49:34.530546 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:34.900432 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:35.537527 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:37.580714 progressemitter.go:285: DEBUG: progress emitter: bytes completed for cg9bu-eiaml: 0
[DHK2G] 2022/01/29 17:49:39.564282 folder.go:175: DEBUG: sendreceive/cg9bu-eiaml@0xc001432000 exiting
[DHK2G] 2022/01/29 17:49:39.564282 quic_listen.go:140: INFO: QUIC listener ([::]:51355) shutting down
[DHK2G] 2022/01/29 17:49:39.564798 progressemitter.go:75: DEBUG: progress emitter: stopping
[DHK2G] 2022/01/29 17:49:39.564805 relay_listen.go:65: INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) shutting down
[DHK2G] 2022/01/29 17:49:40.257533 tcp_listen.go:110: INFO: TCP listener ([::]:51355) shutting down
[DHK2G] 2022/01/29 17:49:40.258058 syncthing.go:353: INFO: Exiting
```

I did the following.

1. Add a new, empty folder to Syncthing.
2. In the folder, create a junction using the command line.
3. Enable `junctionsAsDir` for the folder.
4. Click the "rescan" button, but with no success.
5. Pause and resume the folder.
6. Only now has the junction been detected.
Ah yes, I only thought about the folder config and it's `.Filesystem`. However there's also the `FileSet` with its `.MtimeFS`. Thanks!

Fix patch:
diff --git a/lib/db/set.go b/lib/db/set.go
index 12a7083cb8f..836a5111474 100644
--- a/lib/db/set.go
+++ b/lib/db/set.go
@@ -24,7 +24,6 @@ import (
 
 type FileSet struct {
 	folder string
-	fs     fs.Filesystem
 	db     *Lowlevel
 	meta   *metadataTracker
 
@@ -36,7 +35,7 @@ type FileSet struct {
 // continue iteration, false to stop.
 type Iterator func(f protocol.FileIntf) bool
 
-func NewFileSet(folder string, fs fs.Filesystem, db *Lowlevel) (*FileSet, error) {
+func NewFileSet(folder string, db *Lowlevel) (*FileSet, error) {
 	select {
 	case <-db.oneFileSetCreated:
 	default:
@@ -49,7 +48,6 @@ func NewFileSet(folder string, fs fs.Filesystem, db *Lowlevel) (*FileSet, error)
 	}
 	s := &FileSet{
 		folder:      folder,
-		fs:          fs,
 		db:          db,
 		meta:        meta,
 		updateMutex: sync.NewMutex(),
@@ -405,7 +403,7 @@ func (s *FileSet) SetIndexID(device protocol.DeviceID, id protocol.IndexID) {
 	}
 }
 
-func (s *FileSet) MtimeFS() fs.Filesystem {
+func (s *FileSet) MtimeFS(filesystem fs.Filesystem) fs.Filesystem {
 	opStr := fmt.Sprintf("%s MtimeFS()", s.folder)
 	l.Debugf(opStr)
 	prefix, err := s.db.keyer.GenerateMtimesKey(nil, []byte(s.folder))
@@ -415,7 +413,7 @@ func (s *FileSet) MtimeFS() fs.Filesystem {
 		fatalError(err, opStr, s.db)
 	}
 	kv := NewNamespacedKV(s.db, string(prefix))
-	return fs.NewMtimeFS(s.fs, kv)
+	return fs.NewMtimeFS(filesystem, kv)
 }
 
 func (s *FileSet) ListDevices() []protocol.DeviceID {
diff --git a/lib/model/folder.go b/lib/model/folder.go
index 41b9fe98067..4b645ebd0c6 100644
--- a/lib/model/folder.go
+++ b/lib/model/folder.go
@@ -103,7 +103,7 @@ func newFolder(model *model, fset *db.FileSet, ignores *ignore.Matcher, cfg conf
 		shortID:       model.shortID,
 		fset:          fset,
 		ignores:       ignores,
-		mtimefs:       fset.MtimeFS(),
+		mtimefs:       fset.MtimeFS(cfg.Filesystem()),
 		modTimeWindow: cfg.ModTimeWindow(),
 		done:          make(chan struct{}),
 
diff --git a/lib/model/model.go b/lib/model/model.go
index 12168178704..45536cf4e09 100644
--- a/lib/model/model.go
+++ b/lib/model/model.go
@@ -553,7 +553,7 @@ func (m *model) restartFolder(from, to config.FolderConfiguration, cacheIgnoredF
 			// locking, but it's unsafe to create fset:s concurrently so
 			// that's the price we pay.
 			var err error
-			fset, err = db.NewFileSet(folder, to.Filesystem(), m.db)
+			fset, err = db.NewFileSet(folder, m.db)
 			if err != nil {
 				return fmt.Errorf("restarting %v: %w", to.Description(), err)
 			}
@@ -586,7 +586,7 @@ func (m *model) restartFolder(from, to config.FolderConfiguration, cacheIgnoredF
 func (m *model) newFolder(cfg config.FolderConfiguration, cacheIgnoredFiles bool) error {
 	// Creating the fileset can take a long time (metadata calculation) so
 	// we do it outside of the lock.
-	fset, err := db.NewFileSet(cfg.ID, cfg.Filesystem(), m.db)
+	fset, err := db.NewFileSet(cfg.ID, m.db)
 	if err != nil {
 		return fmt.Errorf("adding %v: %w", cfg.Description(), err)
 	}
@@ -2003,11 +2003,12 @@ func (m *model) CurrentGlobalFile(folder string, file string) (protocol.FileInfo
 func (m *model) GetMtimeMapping(folder string, file string) (fs.MtimeMapping, error) {
 	m.fmut.RLock()
 	ffs, ok := m.folderFiles[folder]
+	fcfg := m.folderCfgs[folder]
 	m.fmut.RUnlock()
 	if !ok {
 		return fs.MtimeMapping{}, ErrFolderMissing
 	}
-	return fs.GetMtimeMapping(ffs.MtimeFS(), file)
+	return fs.GetMtimeMapping(ffs.MtimeFS(fcfg.Filesystem()), file)
 }
 
 // Connection returns the current connection for device, and a boolean whether a connection was found.


Test patch:
diff --git a/lib/db/benchmark_test.go b/lib/db/benchmark_test.go
index d5e31696de8..13838fa3b84 100644
--- a/lib/db/benchmark_test.go
+++ b/lib/db/benchmark_test.go
@@ -11,7 +11,6 @@ import (
 	"testing"
 
 	"github.com/syncthing/syncthing/lib/db"
-	"github.com/syncthing/syncthing/lib/fs"
 	"github.com/syncthing/syncthing/lib/protocol"
 )
 
@@ -47,7 +46,7 @@ func getBenchFileSet(b testing.TB) (*db.Lowlevel, *db.FileSet) {
 	lazyInitBenchFiles()
 
 	ldb := newLowlevelMemory(b)
-	benchS := newFileSet(b, "test)", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	benchS := newFileSet(b, "test)", ldb)
 	replace(benchS, remoteDevice0, files)
 	replace(benchS, protocol.LocalDeviceID, firstHalf)
 
@@ -60,7 +59,7 @@ func BenchmarkReplaceAll(b *testing.B) {
 
 	b.ResetTimer()
 	for i := 0; i < b.N; i++ {
-		m := newFileSet(b, "test)", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+		m := newFileSet(b, "test)", ldb)
 		replace(m, protocol.LocalDeviceID, files)
 	}
 
@@ -202,7 +201,7 @@ func BenchmarkNeedHalf(b *testing.B) {
 func BenchmarkNeedHalfRemote(b *testing.B) {
 	ldb := newLowlevelMemory(b)
 	defer ldb.Close()
-	fset := newFileSet(b, "test)", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	fset := newFileSet(b, "test)", ldb)
 	replace(fset, remoteDevice0, firstHalf)
 	replace(fset, protocol.LocalDeviceID, files)
 
diff --git a/lib/db/db_test.go b/lib/db/db_test.go
index 7ffdc5acf54..020ca289065 100644
--- a/lib/db/db_test.go
+++ b/lib/db/db_test.go
@@ -14,7 +14,6 @@ import (
 
 	"github.com/syncthing/syncthing/lib/db/backend"
 	"github.com/syncthing/syncthing/lib/events"
-	"github.com/syncthing/syncthing/lib/fs"
 	"github.com/syncthing/syncthing/lib/protocol"
 )
 
@@ -42,11 +41,11 @@ func TestIgnoredFiles(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	fs := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), db)
+	fs := newFileSet(t, "test", db)
 
 	// The contents of the database are like this:
 	//
-	// 	fs := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), db)
+	// 	fs := newFileSet(t, "test", db)
 	// 	fs.Update(protocol.LocalDeviceID, []protocol.FileInfo{
 	// 		{ // invalid (ignored) file
 	// 			Name:    "foo",
@@ -498,7 +497,7 @@ func TestCheckGlobals(t *testing.T) {
 	db := newLowlevelMemory(t)
 	defer db.Close()
 
-	fs := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), db)
+	fs := newFileSet(t, "test", db)
 
 	// Add any file
 	name := "foo"
@@ -854,7 +853,7 @@ func TestCheckLocalNeed(t *testing.T) {
 	defer db.Close()
 
 	folderStr := "test"
-	fs := newFileSet(t, folderStr, fs.NewFilesystem(fs.FilesystemTypeFake, ""), db)
+	fs := newFileSet(t, folderStr, db)
 
 	// Add files such that we are in sync for a and b, and need c and d.
 	files := []protocol.FileInfo{
@@ -929,9 +928,8 @@ func TestDuplicateNeedCount(t *testing.T) {
 	defer db.Close()
 
 	folder := "test"
-	testFs := fs.NewFilesystem(fs.FilesystemTypeFake, "")
 
-	fs := newFileSet(t, folder, testFs, db)
+	fs := newFileSet(t, folder, db)
 	files := []protocol.FileInfo{{Name: "foo", Version: protocol.Vector{}.Update(myID), Sequence: 1}}
 	fs.Update(protocol.LocalDeviceID, files)
 	files[0].Version = files[0].Version.Update(remoteDevice0.Short())
@@ -939,7 +937,7 @@ func TestDuplicateNeedCount(t *testing.T) {
 
 	db.checkRepair()
 
-	fs = newFileSet(t, folder, testFs, db)
+	fs = newFileSet(t, folder, db)
 	found := false
 	for _, c := range fs.meta.counts.Counts {
 		if bytes.Equal(protocol.LocalDeviceID[:], c.DeviceID) && c.LocalFlags == needFlag {
@@ -959,9 +957,8 @@ func TestNeedAfterDropGlobal(t *testing.T) {
 	defer db.Close()
 
 	folder := "test"
-	testFs := fs.NewFilesystem(fs.FilesystemTypeFake, "")
 
-	fs := newFileSet(t, folder, testFs, db)
+	fs := newFileSet(t, folder, db)
 
 	// Initial:
 	// Three devices and a file "test": local has Version 1, remoteDevice0
diff --git a/lib/db/meta_test.go b/lib/db/meta_test.go
index 29e3259f075..e68257a706e 100644
--- a/lib/db/meta_test.go
+++ b/lib/db/meta_test.go
@@ -12,7 +12,6 @@ import (
 	"testing"
 
 	"github.com/syncthing/syncthing/lib/events"
-	"github.com/syncthing/syncthing/lib/fs"
 	"github.com/syncthing/syncthing/lib/protocol"
 )
 
@@ -109,7 +108,7 @@ func TestRecalcMeta(t *testing.T) {
 	defer ldb.Close()
 
 	// Add some files
-	s1 := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, "fake"), ldb)
+	s1 := newFileSet(t, "test", ldb)
 	files := []protocol.FileInfo{
 		{Name: "a", Size: 1000},
 		{Name: "b", Size: 2000},
@@ -161,7 +160,7 @@ func TestRecalcMeta(t *testing.T) {
 	}
 
 	// Create a new fileset, which will realize the inconsistency and recalculate
-	s2 := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, "fake"), ldb)
+	s2 := newFileSet(t, "test", ldb)
 
 	// Verify local/global size
 	snap = snapshot(t, s2)
diff --git a/lib/db/set_test.go b/lib/db/set_test.go
index eb7d6ed218f..b479f5aeef9 100644
--- a/lib/db/set_test.go
+++ b/lib/db/set_test.go
@@ -19,7 +19,6 @@ import (
 	"github.com/syncthing/syncthing/lib/db"
 	"github.com/syncthing/syncthing/lib/db/backend"
 	"github.com/syncthing/syncthing/lib/events"
-	"github.com/syncthing/syncthing/lib/fs"
 	"github.com/syncthing/syncthing/lib/protocol"
 )
 
@@ -146,7 +145,7 @@ func TestGlobalSet(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	m := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	m := newFileSet(t, "test", ldb)
 
 	local0 := fileList{
 		protocol.FileInfo{Name: "a", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(1)},
@@ -452,7 +451,7 @@ func TestNeedWithInvalid(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	localHave := fileList{
 		protocol.FileInfo{Name: "a", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(1)},
@@ -493,7 +492,7 @@ func TestUpdateToInvalid(t *testing.T) {
 	defer ldb.Close()
 
 	folder := "test"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 	f := db.NewBlockFinder(ldb)
 
 	localHave := fileList{
@@ -549,7 +548,7 @@ func TestInvalidAvailability(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	remote0Have := fileList{
 		protocol.FileInfo{Name: "both", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(2)},
@@ -591,7 +590,7 @@ func TestGlobalReset(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	m := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	m := newFileSet(t, "test", ldb)
 
 	local := []protocol.FileInfo{
 		{Name: "a", Sequence: 1, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
@@ -630,7 +629,7 @@ func TestNeed(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	m := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	m := newFileSet(t, "test", ldb)
 
 	local := []protocol.FileInfo{
 		{Name: "b", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
@@ -671,7 +670,7 @@ func TestSequence(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	m := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	m := newFileSet(t, "test", ldb)
 
 	local1 := []protocol.FileInfo{
 		{Name: "a", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
@@ -702,7 +701,7 @@ func TestListDropFolder(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s0 := newFileSet(t, "test0", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s0 := newFileSet(t, "test0", ldb)
 	local1 := []protocol.FileInfo{
 		{Name: "a", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
 		{Name: "b", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
@@ -710,7 +709,7 @@ func TestListDropFolder(t *testing.T) {
 	}
 	replace(s0, protocol.LocalDeviceID, local1)
 
-	s1 := newFileSet(t, "test1", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s1 := newFileSet(t, "test1", ldb)
 	local2 := []protocol.FileInfo{
 		{Name: "d", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1002}}}},
 		{Name: "e", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1002}}}},
@@ -753,7 +752,7 @@ func TestGlobalNeedWithInvalid(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test1", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test1", ldb)
 
 	rem0 := fileList{
 		protocol.FileInfo{Name: "a", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1002}}}, Blocks: genBlocks(4)},
@@ -796,7 +795,7 @@ func TestLongPath(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	var b bytes.Buffer
 	for i := 0; i < 100; i++ {
@@ -840,7 +839,7 @@ func BenchmarkUpdateOneFile(b *testing.B) {
 		os.RemoveAll("testdata/benchmarkupdate.db")
 	}()
 
-	m := newFileSet(b, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	m := newFileSet(b, "test", ldb)
 	replace(m, protocol.LocalDeviceID, local0)
 	l := local0[4:5]
 
@@ -856,7 +855,7 @@ func TestIndexID(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	// The Index ID for some random device is zero by default.
 	id := s.IndexID(remoteDevice0)
@@ -888,7 +887,7 @@ func TestIndexID(t *testing.T) {
 func TestDropFiles(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 
-	m := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	m := newFileSet(t, "test", ldb)
 
 	local0 := fileList{
 		protocol.FileInfo{Name: "a", Sequence: 1, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(1)},
@@ -952,7 +951,7 @@ func TestIssue4701(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	localHave := fileList{
 		protocol.FileInfo{Name: "a", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
@@ -995,7 +994,7 @@ func TestWithHaveSequence(t *testing.T) {
 	defer ldb.Close()
 
 	folder := "test"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	// The files must not be in alphabetical order
 	localHave := fileList{
@@ -1033,7 +1032,7 @@ func TestStressWithHaveSequence(t *testing.T) {
 	defer ldb.Close()
 
 	folder := "test"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	var localHave []protocol.FileInfo
 	for i := 0; i < 100; i++ {
@@ -1078,7 +1077,7 @@ func TestIssue4925(t *testing.T) {
 	defer ldb.Close()
 
 	folder := "test"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	localHave := fileList{
 		protocol.FileInfo{Name: "dir"},
@@ -1106,7 +1105,7 @@ func TestMoveGlobalBack(t *testing.T) {
 
 	folder := "test"
 	file := "foo"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	localHave := fileList{{Name: file, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1}}}, Blocks: genBlocks(1), ModifiedS: 10, Size: 1}}
 	remote0Have := fileList{{Name: file, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1}, {ID: remoteDevice0.Short(), Value: 1}}}, Blocks: genBlocks(2), ModifiedS: 0, Size: 2}}
@@ -1175,7 +1174,7 @@ func TestIssue5007(t *testing.T) {
 
 	folder := "test"
 	file := "foo"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	fs := fileList{{Name: file, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1}}}}}
 
@@ -1205,7 +1204,7 @@ func TestNeedDeleted(t *testing.T) {
 
 	folder := "test"
 	file := "foo"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	fs := fileList{{Name: file, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1}}}, Deleted: true}}
 
@@ -1242,7 +1241,7 @@ func TestReceiveOnlyAccounting(t *testing.T) {
 	defer ldb.Close()
 
 	folder := "test"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	local := protocol.DeviceID{1}
 	remote := protocol.DeviceID{2}
@@ -1348,7 +1347,7 @@ func TestNeedAfterUnignore(t *testing.T) {
 
 	folder := "test"
 	file := "foo"
-	s := newFileSet(t, folder, fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, folder, ldb)
 
 	remID := remoteDevice0.Short()
 
@@ -1379,7 +1378,7 @@ func TestRemoteInvalidNotAccounted(t *testing.T) {
 
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	files := []protocol.FileInfo{
 		{Name: "a", Size: 1234, Sequence: 42, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1003}}}},                   // valid, should count
@@ -1400,7 +1399,7 @@ func TestNeedWithNewerInvalid(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "default", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "default", ldb)
 
 	rem0ID := remoteDevice0.Short()
 	rem1ID := remoteDevice1.Short()
@@ -1442,7 +1441,7 @@ func TestNeedAfterDeviceRemove(t *testing.T) {
 	defer ldb.Close()
 
 	file := "foo"
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	fs := fileList{{Name: file, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1}}}}}
 
@@ -1469,7 +1468,7 @@ func TestCaseSensitive(t *testing.T) {
 
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	local := []protocol.FileInfo{
 		{Name: filepath.FromSlash("D1/f1"), Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
@@ -1507,7 +1506,7 @@ func TestSequenceIndex(t *testing.T) {
 
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	local := []protocol.FileInfo{
 		{Name: filepath.FromSlash("banana"), Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}},
@@ -1603,7 +1602,7 @@ func TestIgnoreAfterReceiveOnly(t *testing.T) {
 	defer ldb.Close()
 
 	file := "foo"
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeBasic, "."), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	fs := fileList{{
 		Name:       file,
@@ -1634,7 +1633,7 @@ func TestUpdateWithOneFileTwice(t *testing.T) {
 	defer ldb.Close()
 
 	file := "foo"
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	fs := fileList{{
 		Name:     file,
@@ -1671,7 +1670,7 @@ func TestNeedRemoteOnly(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	remote0Have := fileList{
 		protocol.FileInfo{Name: "b", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(2)},
@@ -1689,7 +1688,7 @@ func TestNeedRemoteAfterReset(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	files := fileList{
 		protocol.FileInfo{Name: "b", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(2)},
@@ -1715,7 +1714,7 @@ func TestIgnoreLocalChanged(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	// Add locally changed file
 	files := fileList{
@@ -1749,7 +1748,7 @@ func TestNoIndexIDResetOnDrop(t *testing.T) {
 	ldb := newLowlevelMemory(t)
 	defer ldb.Close()
 
-	s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
+	s := newFileSet(t, "test", ldb)
 
 	s.SetIndexID(remoteDevice0, 1)
 	s.Drop(remoteDevice0)
@@ -1772,7 +1771,7 @@ func TestConcurrentIndexID(t *testing.T) {
 	}
 	for i := 0; i < max; i++ {
 		ldb := newLowlevelMemory(t)
-		s := newFileSet(t, "test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
+		s := newFileSet(t, "test", ldb)
 		go setID(s, 0)
 		go setID(s, 1)
 		<-done
@@ -1789,9 +1788,8 @@ func TestNeedRemoveLastValid(t *testing.T) {
 	defer db.Close()
 
 	folder := "test"
-	testFs := fs.NewFilesystem(fs.FilesystemTypeFake, "")
 
-	fs := newFileSet(t, folder, testFs, db)
+	fs := newFileSet(t, folder, db)
 
 	files := []protocol.FileInfo{
 		{Name: "foo", Version: protocol.Vector{}.Update(myID), Sequence: 1},
@@ -1887,9 +1885,9 @@ func newLowlevelMemory(t testing.TB) *db.Lowlevel {
 	return newLowlevel(t, backend.OpenMemory())
 }
 
-func newFileSet(t testing.TB, folder string, fs fs.Filesystem, ll *db.Lowlevel) *db.FileSet {
+func newFileSet(t testing.TB, folder string, ll *db.Lowlevel) *db.FileSet {
 	t.Helper()
-	fset, err := db.NewFileSet(folder, fs, ll)
+	fset, err := db.NewFileSet(folder, ll)
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/lib/db/util_test.go b/lib/db/util_test.go
index 0ea8c55bbb2..032a487e88f 100644
--- a/lib/db/util_test.go
+++ b/lib/db/util_test.go
@@ -14,8 +14,6 @@ import (
 
 	"github.com/syncthing/syncthing/lib/db/backend"
 	"github.com/syncthing/syncthing/lib/events"
-	"github.com/syncthing/syncthing/lib/fs"
-	// "github.com/syncthing/syncthing/lib/protocol"
 )
 
 // writeJSONS serializes the database to a JSON stream that can be checked
@@ -83,9 +81,9 @@ func newLowlevelMemory(t testing.TB) *Lowlevel {
 	return newLowlevel(t, backend.OpenMemory())
 }
 
-func newFileSet(t testing.TB, folder string, fs fs.Filesystem, db *Lowlevel) *FileSet {
+func newFileSet(t testing.TB, folder string, db *Lowlevel) *FileSet {
 	t.Helper()
-	fset, err := NewFileSet(folder, fs, db)
+	fset, err := NewFileSet(folder, db)
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/lib/model/folder_sendrecv_test.go b/lib/model/folder_sendrecv_test.go
index c3a76424286..4999e99b5d0 100644
--- a/lib/model/folder_sendrecv_test.go
+++ b/lib/model/folder_sendrecv_test.go
@@ -805,8 +805,8 @@ func TestCopyOwner(t *testing.T) {
 	f.folder.FolderConfiguration = newFolderConfiguration(m.cfg, f.ID, f.Label, fs.FilesystemTypeFake, "/TestCopyOwner")
 	f.folder.FolderConfiguration.CopyOwnershipFromParent = true
 
-	f.fset = newFileSet(t, f.ID, f.Filesystem(), m.db)
-	f.mtimefs = f.fset.MtimeFS()
+	f.fset = newFileSet(t, f.ID, m.db)
+	f.mtimefs = f.fset.MtimeFS(f.Filesystem())
 
 	// Create a parent dir with a certain owner/group.
 
diff --git a/lib/model/model_test.go b/lib/model/model_test.go
index 03ead535558..eac0b69fece 100644
--- a/lib/model/model_test.go
+++ b/lib/model/model_test.go
@@ -1621,7 +1621,7 @@ func TestROScanRecovery(t *testing.T) {
 	defer cancel()
 	m := newModel(t, cfg, myID, "syncthing", "dev", nil)
 
-	set := newFileSet(t, "default", defaultFs, m.db)
+	set := newFileSet(t, "default", m.db)
 	set.Update(protocol.LocalDeviceID, []protocol.FileInfo{
 		{Name: "dummyfile", Version: protocol.Vector{Counters: []protocol.Counter{{ID: 42, Value: 1}}}},
 	})
@@ -1676,7 +1676,7 @@ func TestRWScanRecovery(t *testing.T) {
 
 	testOs.RemoveAll(fcfg.Path)
 
-	set := newFileSet(t, "default", defaultFs, m.db)
+	set := newFileSet(t, "default", m.db)
 	set.Update(protocol.LocalDeviceID, []protocol.FileInfo{
 		{Name: "dummyfile", Version: protocol.Vector{Counters: []protocol.Counter{{ID: 42, Value: 1}}}},
 	})
@@ -2177,7 +2177,7 @@ func TestIssue2782(t *testing.T) {
 func TestIndexesForUnknownDevicesDropped(t *testing.T) {
 	m := newModel(t, defaultCfgWrapper, myID, "syncthing", "dev", nil)
 
-	files := newFileSet(t, "default", defaultFs, m.db)
+	files := newFileSet(t, "default", m.db)
 	files.Drop(device1)
 	files.Update(device1, genFiles(1))
 	files.Drop(device2)
@@ -2191,7 +2191,7 @@ func TestIndexesForUnknownDevicesDropped(t *testing.T) {
 	defer cleanupModel(m)
 
 	// Remote sequence is cached, hence need to recreated.
-	files = newFileSet(t, "default", defaultFs, m.db)
+	files = newFileSet(t, "default", m.db)
 
 	if l := len(files.ListDevices()); l != 1 {
 		t.Errorf("Expected one device got %v", l)
@@ -2622,7 +2622,7 @@ func TestCustomMarkerName(t *testing.T) {
 	testOs.RemoveAll(fcfg.Path)
 
 	m := newModel(t, cfg, myID, "syncthing", "dev", nil)
-	set := newFileSet(t, "default", defaultFs, m.db)
+	set := newFileSet(t, "default", m.db)
 	set.Update(protocol.LocalDeviceID, []protocol.FileInfo{
 		{Name: "dummyfile"},
 	})
diff --git a/lib/model/testutils_test.go b/lib/model/testutils_test.go
index a31e57fdd32..e1660783977 100644
--- a/lib/model/testutils_test.go
+++ b/lib/model/testutils_test.go
@@ -307,7 +307,7 @@ func fsetSnapshot(t *testing.T, fset *db.FileSet) *db.Snapshot {
 func folderIgnoresAlwaysReload(t testing.TB, m *testModel, fcfg config.FolderConfiguration) {
 	t.Helper()
 	m.removeFolder(fcfg)
-	fset := newFileSet(t, fcfg.ID, fcfg.Filesystem(), m.db)
+	fset := newFileSet(t, fcfg.ID, m.db)
 	ignores := ignore.New(fcfg.Filesystem(), ignore.WithCache(true), ignore.WithChangeDetector(newAlwaysChanged()))
 	m.fmut.Lock()
 	m.addAndStartFolderLockedWithIgnores(fcfg, fset, ignores)
@@ -359,9 +359,9 @@ func newDeviceConfiguration(defaultCfg config.DeviceConfiguration, id protocol.D
 	return cfg
 }
 
-func newFileSet(t testing.TB, folder string, fs fs.Filesystem, ldb *db.Lowlevel) *db.FileSet {
+func newFileSet(t testing.TB, folder string, ldb *db.Lowlevel) *db.FileSet {
 	t.Helper()
-	fset, err := db.NewFileSet(folder, fs, ldb)
+	fset, err := db.NewFileSet(folder, ldb)
 	if err != nil {
 		t.Fatal(err)
 	}