Quellcode durchsuchen

remote: show path in PathNotAllowed

not 100 % sure whether "if old_server" is required, so let's play it safe.
1.0 -> 1.1 server is no problem.
Marian Beermann vor 8 Jahren
Ursprung
Commit
8dfe2a8080
2 geänderte Dateien mit 8 neuen und 4 gelöschten Zeilen
  1. 6 3
      src/borg/remote.py
  2. 2 1
      src/borg/testsuite/repository.py

+ 6 - 3
src/borg/remote.py

@@ -87,7 +87,7 @@ class ConnectionClosedWithHint(ConnectionClosed):
 
 
 
 
 class PathNotAllowed(Error):
 class PathNotAllowed(Error):
-    """Repository path not allowed"""
+    """Repository path not allowed: {}"""
 
 
 
 
 class InvalidRPCMethod(Error):
 class InvalidRPCMethod(Error):
@@ -391,7 +391,7 @@ class RepositoryServer:  # pragma: no cover
         elif kind == 'IntegrityError':
         elif kind == 'IntegrityError':
             raise IntegrityError(s1)
             raise IntegrityError(s1)
         elif kind == 'PathNotAllowed':
         elif kind == 'PathNotAllowed':
-            raise PathNotAllowed()
+            raise PathNotAllowed('foo')
         elif kind == 'ObjectNotFound':
         elif kind == 'ObjectNotFound':
             raise Repository.ObjectNotFound(s1, s2)
             raise Repository.ObjectNotFound(s1, s2)
         elif kind == 'InvalidRPCMethod':
         elif kind == 'InvalidRPCMethod':
@@ -747,7 +747,10 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
                 else:
                 else:
                     raise IntegrityError(args[0].decode())
                     raise IntegrityError(args[0].decode())
             elif error == 'PathNotAllowed':
             elif error == 'PathNotAllowed':
-                raise PathNotAllowed()
+                if old_server:
+                    raise PathNotAllowed('(unknown)')
+                else:
+                    raise PathNotAllowed(args[0].decode())
             elif error == 'ObjectNotFound':
             elif error == 'ObjectNotFound':
                 if old_server:
                 if old_server:
                     raise Repository.ObjectNotFound('(not available)', self.location.orig)
                     raise Repository.ObjectNotFound('(not available)', self.location.orig)

+ 2 - 1
src/borg/testsuite/repository.py

@@ -815,7 +815,8 @@ class RemoteRepositoryTestCase(RepositoryTestCase):
         try:
         try:
             self.repository.call('inject_exception', {'kind': 'PathNotAllowed'})
             self.repository.call('inject_exception', {'kind': 'PathNotAllowed'})
         except PathNotAllowed as e:
         except PathNotAllowed as e:
-            assert len(e.args) == 0
+            assert len(e.args) == 1
+            assert e.args[0] == 'foo'
 
 
         try:
         try:
             self.repository.call('inject_exception', {'kind': 'ObjectNotFound'})
             self.repository.call('inject_exception', {'kind': 'ObjectNotFound'})