瀏覽代碼

Merge pull request #1408 from ThomasWaldmann/fix-remote-repo-teardown

RemoteRepository init: always call close on exceptions, fixes #1370
enkore 8 年之前
父節點
當前提交
2e969a7418
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      borg/remote.py

+ 6 - 6
borg/remote.py

@@ -170,12 +170,12 @@ class RemoteRepository:
         self.x_fds = [self.stdin_fd, self.stdout_fd, self.stderr_fd]
 
         try:
-            version = self.call('negotiate', RPC_PROTOCOL_VERSION)
-        except ConnectionClosed:
-            raise ConnectionClosedWithHint('Is borg working on the server?') from None
-        if version != RPC_PROTOCOL_VERSION:
-            raise Exception('Server insisted on using unsupported protocol version %d' % version)
-        try:
+            try:
+                version = self.call('negotiate', RPC_PROTOCOL_VERSION)
+            except ConnectionClosed:
+                raise ConnectionClosedWithHint('Is borg working on the server?') from None
+            if version != RPC_PROTOCOL_VERSION:
+                raise Exception('Server insisted on using unsupported protocol version %d' % version)
             # Because of protocol versions, only send append_only if necessary
             if append_only:
                 try: