From 872e161ec2714a8cbdea09bb70d847f2c89f35f8 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 6 Jan 2025 10:32:47 -0800 Subject: [PATCH] backups: Handle error when there is not enough space on disk Tests: - Fill up disk to have very little space left. Perform a large backup operation by writing a large file to one of the directories to be backed up. Try to perform the backup and notice that a nice error message is shown that there is not enough disk space instead of a generic error message. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/backups/errors.py | 4 ++++ plinth/modules/backups/privileged.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/plinth/modules/backups/errors.py b/plinth/modules/backups/errors.py index 70d4f0601..2792f6741 100644 --- a/plinth/modules/backups/errors.py +++ b/plinth/modules/backups/errors.py @@ -33,3 +33,7 @@ class BorgArchiveDoesNotExist(BorgError): class BorgBusy(BorgError): """Borg could not acquire lock being busy with another operation.""" + + +class BorgNoSpace(BorgError): + """There is not enough space left on the device to perform operation.""" diff --git a/plinth/modules/backups/privileged.py b/plinth/modules/backups/privileged.py index bc3cf6b02..2a8118978 100644 --- a/plinth/modules/backups/privileged.py +++ b/plinth/modules/backups/privileged.py @@ -87,6 +87,11 @@ KNOWN_ERRORS = [ 'message': _('Backup system is busy with another operation.'), 'raise_as': errors.BorgBusy, }, + { + 'errors': ['No space left on device'], + 'message': _('Not enough space left on the disk or remote location.'), + 'raise_as': errors.BorgNoSpace, + }, ]