Sunil Mohan Adapa e0aef43ece
backups: Handle common errors during borg operations
Closes: #2218.

- When borg can't acquire a lock due to it being busy, any borg operation can
fail. Show a readable message instead of a generic error.

- Also handle errors for archive already existing and archive to be deleted not
existing.

Tests:

- Functional tests for backup app work.

- Creating archive works with proper message. Providing the name of existing
archive shows proper error.

- Deleting archive works with proper message. Open two tabs by clicking on the
delete archive button. Then delete with one and try to delete the it again with
the next one. Proper error message is shown.

- While downloading an archive, delete an archive. Proper error message that
borg is busy is shown.

- Upload archive works. A proper success message is shown.

- Restore backup from archive works. A proper success message is shown.

- Restore backup from file upload works. A proper success message is shown after
upload and after restoration.

- Adding local repository works. A proper success message is shown.

- Adding remote repository works. A proper success message is shown when SSH key
is verified and repository is added.

- Removing repository works. A proper success message is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-12-30 08:34:14 -05:00

36 lines
895 B
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
from plinth.errors import PlinthError
class BorgError(PlinthError):
"""Generic borg errors"""
class BorgRepositoryDoesNotExistError(BorgError):
"""Borg access to a repository works but the repository does not exist"""
class SshfsError(PlinthError):
"""Generic sshfs errors"""
class BorgRepositoryExists(BorgError):
"""A repository at target location already exists during initialization."""
class BorgUnencryptedRepository(BorgError):
"""Attempt to provide password on an unencrypted repository."""
class BorgArchiveExists(BorgError):
"""A archive with the given name already exists in the repository."""
class BorgArchiveDoesNotExist(BorgError):
"""Specified archive does not exist in the repository."""
class BorgBusy(BorgError):
"""Borg could not acquire lock being busy with another operation."""