canton7 / SyncTrayzor

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

Devices "auto-unpause" after restart #391

Open scienmind opened 7 years ago

scienmind commented 7 years ago

Following up to the discussion in ST's repo: https://github.com/syncthing/syncthing/issues/4279

Seems like SyncTrayzor might be the one to blame for unpausing the folders on startup despite the config. That's what I found in the logs:

 2017-08-01 08:49:27.9106 #3744 [Debug] SyncTrayzor.Syncthing.SyncthingProcessRunner: [IDIDIDID-16] 08:49:27 INFO: GUI and API listening on [::]:PORT-2 
 2017-08-01 08:49:27.9106 #3744 [Debug] SyncTrayzor.Syncthing.SyncthingProcessRunner: [IDIDIDID-16] 08:49:27 INFO: Access the GUI via the following URL: https://127.0.0.1:PORT-2/ 
 2017-08-01 08:49:28.3770 #3744 [Debug] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClient: Fetched version: <Version arch=amd64 longVersion=syncthing v0.14.33 "Dysprosium Dragonfly" (go1.8.3 windows-amd64) DESKTOP-V6RD4NK\Admin@DESKTOP-V6RD4NK 2017-07-13 06:55:12 UTC os=windows version=v0.14.33> 
 2017-08-01 08:49:28.3770 #3744 [Debug] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClientFactory: Success! 
 2017-08-01 08:49:28.3770 #3744 [Debug] SyncTrayzor.Syncthing.SyncthingManager: Have the API client! It's SyncthingApiClient 
 2017-08-01 08:49:28.3770 #3744 [Debug] SyncTrayzor.Syncthing.SyncthingManager: Request to set state: Starting -> Running 
 2017-08-01 08:49:28.3770 #3744 [Debug] SyncTrayzor.Syncthing.SyncthingManager: Setting state: Starting -> Running 
 2017-08-01 08:49:28.4281 #3744 [Debug] SyncTrayzor.Syncthing.SyncthingManager: Startup Complete! Loading startup data 
 2017-08-01 08:49:28.4591 #3744 [Debug] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClient: Fetched version: <Version arch=amd64 longVersion=syncthing v0.14.33 "Dysprosium Dragonfly" (go1.8.3 windows-amd64) DESKTOP-V6RD4NK\Admin@DESKTOP-V6RD4NK 2017-07-13 06:55:12 UTC os=windows version=v0.14.33> 
 2017-08-01 08:49:28.5062 #3744 [Debug] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClient: Fetched system info: <SystemInfo alloc=25613656 cpuPercent=0 goroutines=65 myId=IDIDIDIDID-16-FULL-ID pathSeparator=\ sys=106150136 tilde=C:\Users\USER-1> 
 2017-08-01 08:49:28.5502 #3744 [Debug] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClient: Got debug facilities: <DebugFacilities Enabled= Facilities=beacon=Multicast and broadcast discovery,config=Configuration loading and saving,connections=Connection handling,db=The database layer,dialer=Dialing connections,discover=Remote device discovery,events=Event generation and logging,http=REST API,main=Main package,model=The root hub,nat=NAT discovery and port mapping,pmp=NAT-PMP discovery and port mapping,protocol=The BEP protocol,scanner=File change detection and hashing,sha256=SHA256 hashing package,stats=Persistent device and folder statistics,sync=Mutexes,upgrade=Binary upgrades,upnp=UPnP discovery and port mapping,versioner=File versioning> 
 2017-08-01 08:49:28.5502 #3744 [Debug] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClient: Fetched configuration: <Config version=20 folders=[<Folder id=FOLDER-33 label= path=W:\FOLDER-33-PATH devices=[<Device deviceId=IDIDIDIDID-16-FULL-ID>, <Device deviceId=IDIDIDID-8-FULL-ID>] rescalinterval=00:15:00 invalid=>] devices=[Device id=IDIDIDIDID-16-FULL-ID name=DEVICE-16 addresses=[dynamic] compression=N/A certname= isintroducer=False>, Device id=IDIDIDID-8-FULL-ID name=DEVICE-8 addresses=[dynamic] compression=N/A certname= isintroducer=False>]> 
 2017-08-01 08:50:25.0900 #3744 [Debug] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClient: Fetched folder status for folder FOLDER-33: <FolderStatus GlobalBytes=5240675678268 GlobalDeleted=3209 GlobalFiles=12982 LocalBytes=2623097588087 LocalDeleted=9475 LocalFiles=6777 InSyncBytes=2623097529463 InSyncFiles=6777 NeedBytes=2617578148805 NeedFiles=6205 Invalid= State=scanning StateChanged=01-Aug-17 08:49:27 Version=42196> 
 2017-08-01 08:50:25.1070 #3744 [Debug] SyncTrayzor.Services.Conflicts.ConflictFileWatcher: Starting watcher for folder: FOLDER-33 (FOLDER-33) 
 2017-08-01 08:50:25.1130 #3744 [Debug] SyncTrayzor.Services.Conflicts.ConflictFileWatcher: Scanning folder FOLDER-33 (FOLDER-33) (W:\FOLDER-33-PATH) for conflict files 
 2017-08-01 08:50:25.2321 #3744 [Debug] SyncTrayzor.Services.Conflicts.ConflictFileManager: Looking for conflicts in W:\FOLDER-33-PATH 
 2017-08-01 08:50:25.2531 #3744 [Info] SyncTrayzor.Services.Metering.MeteredNetworkManager: Resuming device IDIDIDID-8-FULL-ID 
 2017-08-01 08:50:25.2951 #3744 [Info] SyncTrayzor.Syncthing.ApiClient.SyncthingApiClient: Resuming device IDIDIDID-8-FULL-ID 
 2017-08-01 08:50:25.3171 #3744 [Debug] SyncTrayzor.Services.Config.ConfigurationProvider: Saving configuration atomically: <Configuration ShowTrayIconOnlyOnClose=False MinimizeToTray=False CloseToTray=True ShowDeviceConnectivityBalloons=False ShowDeviceOrFolderRejectedBalloons=True SyncthingAddress=0.0.0.0:PORT-2 StartSyncthingAutomatically=True SyncthingCommandLineFlags=[]SyncthingApiKey=API-KEY-1 SyncthingEnvironmentalVariables=[] SyncthingDenyUpgrade=False SyncthingPriorityLevel=BelowNormal Folders=[<Folder ID=FOLDER-33 IsWatched=True NotificationsEnabled=True>] NotifyOfNewVersions=True LatestNotifiedVersion= ObfuscateDeviceIDs=True UseComputerCulture=False SyncthingConsoleHeight=196 WindowPlacement=<WindowPlacement IsMaximized=False MinPosition={X=-32000,Y=-32000} MaxPosition={X=-1,Y=-1} Normalposition={X=404,Y=72,Width=1035,Height=950}> SyncthingWebBrowserZoomLevel=-1 LastSeenInstallCount=3 SyncthingCustomPath= SyncthingCustomHomePath= ShowSynchronizedBalloonEvenIfNothingDownloaded=False DisableHardwareRendering=False EnableFailedTransferAlerts=True EnableConflictFileMonitoring=True SyncthingDebugFacilities=[] ConflictResolverDeletesToRecycleBin=True PauseDevicesOnMeteredNetworks=True HaveDonated=False IconAnimationMode=DataTransferring OpenFolderCommand=explorer.exe "{0}" ShowFileInFolderCommand=explorer.exe /select, "{0}"> 
 2017-08-01 08:50:26.0706 #3744 [Debug] SyncTrayzor.Syncthing.EventWatcher.SyncthingEventWatcher: Received 1 events 
 2017-08-01 08:50:26.0796 #3744 [Debug] SyncTrayzor.Syncthing.EventWatcher.SyncthingEventWatcher: <DeviceResumed ID=8 Time=01-Aug-17 08:50:25 DeviceId=IDIDIDID-8-FULL-ID> 
 2017-08-01 08:51:26.0927 #3744 [Debug] SyncTrayzor.Syncthing.EventWatcher.SyncthingEventWatcher: Received 0 events 
 2017-08-01 08:52:26.1059 #3744 [Debug] SyncTrayzor.Syncthing.EventWatcher.SyncthingEventWatcher: Received 0 events 
 2017-08-01 08:52:54.4233 #3744 [Debug] SyncTrayzor.Syncthing.EventWatcher.SyncthingEventWatcher: Received 1 events

Syncthing v.0.14.33 SyncTrayzor v.1.1.16

scienmind commented 7 years ago

Just a friendly reminder - this one makes pausing devices nearly unusable (unless using ST withough SyncTrayzor) 😉

canton7 commented 7 years ago

Note to self: load config on startup, mark devices which are paused as PausedRenegade.

canton7 commented 7 years ago

Actually that won't work. If we:

  1. Are not on a metered connection, devices not paused
  2. Move into a metered connection, devices become paused
  3. Restart the PC
  4. Join a non-metered connection

Then we won't unpause those devices.

I don't think there's any way to win here. We're massively abusing the ability to pause devices for this anyway, and there are some rough edges that can't be solved. I think you have to accept that either you manually pause/unpause devices (and disabled the metered connection stuff), or leave the metered connection stuff on but don't pause/unpause devices yourself.

Maybe the thing to do is to disable the metered connection stuff by default, and add a disclaimer to the settings item.

scienmind commented 7 years ago

Maybe it's possible to store "pausing authorship" somewhere? So that synctrayzor would be able to differentiate manual pausing from auto-pausing due to metered connection, and will then know not to automatically override the "manual" stuff