canton7 / SyncTrayzor

Windows tray utility / filesystem watcher / launcher for Syncthing
MIT License
5.98k stars 412 forks source link

SyncTrayzor prevents ejecting USB drive #788

Open ARF1 opened 1 year ago

ARF1 commented 1 year ago

I have two "receive only"-folders on a removable USB disk. The folder watcher is disabled for both folders. However, even with the folder watcher disabled, it is impossible to safely remove the drive while SyncTrayzor is running.

To reproduce:

  1. Create a folder on an USB drive
  2. Set the folder as "receive only" (not essential to demonstrate the problem)
  3. Disable the folder watcher in SyncTrayzor for the folder on the USB drive
  4. Using the Windows 10 tray icon "Safely Remove Hardware and Eject Media", try to eject the USB drive with the Syncthing folder
  5. Error message titled "Problem Ejecting USB Composite Device": "This device is currently in use. Close any programs or windows that might be using the device and then try again."
  6. Terminate SyncTrayzor
  7. Try ejecting the USB drive again --> Success

I suspect that SyncTrayzor needs to use some Windows api to register to receive a notification when a user tries to eject hardware. SyncTrayzor can then close all its relevant file pointers, if the user tries to eject a drive that SyncTrayzor is using, to allow Windows to eject the drive.