samschott / maestral

Open-source Dropbox client for macOS and Linux
https://maestral.app
MIT License
3.12k stars 64 forks source link

Sync pauses unexpected in Docker container on Synology DSM (/sys/class/power_supply missing) #877

Closed nestingBiscuit closed 1 year ago

nestingBiscuit commented 1 year ago

Describe the bug Every time I edited or added a new file the sync status changed to paused.

Log:

2023-04-15 10:09:15 manager INFO: Up to date
2023-04-15 10:09:17 manager ERROR: Unexpected error
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/maestral/manager.py", line 802, in _handle_sync_thread_errors
    yield
  File "/usr/local/lib/python3.10/site-packages/maestral/manager.py", line 650, in download_worker
    if self._should_rebuild_index():
  File "/usr/local/lib/python3.10/site-packages/maestral/manager.py", line 400, in _should_rebuild_index
    ac_state = get_ac_state()
  File "/usr/local/lib/python3.10/site-packages/maestral/utils/integration.py", line 84, in get_ac_state
    supply_entry = list(os.scandir(LINUX_POWER_SUPPLY_PATH))
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/power_supply'
2023-04-15 10:09:17 manager INFO: Shutting down threads...
2023-04-15 10:09:17 sync INFO: Sync aborted
2023-04-15 10:09:17 manager INFO: Paused

It appears to be caused by the missing '/sys/class/power_supply'.

Potential Fix:

I changed line 84 in src/maestral/utils/integration.py to:

try:                                                           
    supply_entry = list(os.scandir(LINUX_POWER_SUPPLY_PATH))   
except FileNotFoundError:                                      
    return ACState.Undetermined 

That has fixed the issue for me.


To Reproduce Create and run a docker container from maestraldbx/maestral:1.7.1 on Synology DSM 7.0.1 - or any other system that does not provide '/sys/class/power_supply'. After initial sync - Check status -> Up to date Create a new file in dropbox. - Check status -> Paused Logs show the error message above.

Expected behaviour Expected not to pause sync.

System:

samschott commented 1 year ago

Thanks the report, this should indeed be handled better. Since you already have a fix, care to submit a PR?

nestingBiscuit commented 1 year ago

Thanks the report, this should indeed be handled better. Since you already have a fix, care to submit a PR?

I am unfamiliar with git and github - so I don't know how to do a pull request. But I will look into it and figure it out 👍