mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
backups: Improve handling borg errors
- Use regular expression search instead of string search. - Fix issue with incorrect password error not getting recognized properly. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
77a93d967f
commit
c159c484ec
@ -23,6 +23,7 @@ import io
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from uuid import uuid1
|
from uuid import uuid1
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -64,12 +65,9 @@ KNOWN_ERRORS = [{
|
|||||||
BorgRepositoryDoesNotExistError,
|
BorgRepositoryDoesNotExistError,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'errors': [('passphrase supplied in BORG_PASSPHRASE or by '
|
'errors': [('passphrase supplied in .* is incorrect')],
|
||||||
'BORG_PASSCOMMAND is incorrect')],
|
'message': _('Incorrect encryption passphrase'),
|
||||||
'message':
|
'raise_as': BorgError,
|
||||||
_('Incorrect encryption passphrase'),
|
|
||||||
'raise_as':
|
|
||||||
BorgError,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'errors': [('Connection reset by peer')],
|
'errors': [('Connection reset by peer')],
|
||||||
@ -255,7 +253,7 @@ class BaseBorgRepository(abc.ABC):
|
|||||||
caught_error = str(err)
|
caught_error = str(err)
|
||||||
for known_error in KNOWN_ERRORS:
|
for known_error in KNOWN_ERRORS:
|
||||||
for error in known_error['errors']:
|
for error in known_error['errors']:
|
||||||
if error in caught_error:
|
if re.search(error, caught_error):
|
||||||
raise known_error['raise_as'](known_error['message'])
|
raise known_error['raise_as'](known_error['message'])
|
||||||
|
|
||||||
raise err
|
raise err
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user