Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FileNotFoundError exception in mount.mounted #1157

Merged
merged 1 commit into from
Jul 4, 2021

Conversation

tatokis
Copy link
Contributor

@tatokis tatokis commented Apr 25, 2021

If the user manually unmounts the drive containing the mount dir in the user-callback script, then os.listdir(self.currentMountpoint) will throw an exception, as the directory won't exist.

This PR avoids the following exception

INFO: mount ssh: backups@domain:/media/user/drive/path on /home/user/.local/share/backintime/mnt/ID/mountpoint
[...]
INFO: Create info file
Traceback (most recent call last):
  File "/usr/share/backintime/common/backintime.py", line 1165, in <module>
    startApp()
  File "/usr/share/backintime/common/backintime.py", line 517, in startApp
    args.func(args)
  File "/usr/share/backintime/common/backintime.py", line 739, in backup
    ret = takeSnapshot(cfg, force)
  File "/usr/share/backintime/common/backintime.py", line 94, in takeSnapshot
    ret = snapshots.Snapshots(cfg).backup(force)
  File "/usr/share/backintime/common/snapshots.py", line 733, in backup
    mount.Mount(cfg = self.config).umount(self.config.current_hash_id)
  File "/usr/share/backintime/common/mount.py", line 178, in umount
    backend.umount()
  File "/usr/share/backintime/common/mount.py", line 449, in umount
    if not self.mounted():
  File "/usr/share/backintime/common/mount.py", line 610, in mounted
    if os.listdir(self.currentMountpoint):
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.local/share/backintime/mnt/ID/mountpoint'

This occurs because the user script in my case remotely does the following

ssh domain -p 25 -l backups sudo umount /media/user/drive

If the user manually unmounts the drive containing the mount dir
in the user-callback script, then os.listdir(self.currentMountpoint)
will throw an exception, as the directory doesn't exist.
@Germar Germar merged commit 1511422 into bit-team:master Jul 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants