changeset 6563:3b6f18851d87

sshserver: Don't try to close fp if mkstemp failed
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 23 Apr 2008 11:40:33 +0200
parents 090f2145df7d
children ccc2481e3954
files mercurial/sshserver.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshserver.py	Fri Apr 18 18:07:34 2008 +0200
+++ b/mercurial/sshserver.py	Wed Apr 23 11:40:33 2008 +0200
@@ -167,7 +167,7 @@
         self.respond('')
 
         # write bundle data to temporary file because it can be big
-
+        tempname = fp = None
         try:
             fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
             fp = os.fdopen(fd, 'wb+')
@@ -198,8 +198,10 @@
                     self.lock.release()
                     self.lock = None
         finally:
-            fp.close()
-            os.unlink(tempname)
+            if fp is not None:
+                fp.close()
+            if tempname is not None:
+                os.unlink(tempname)
 
     def do_stream_out(self):
         streamclone.stream_out(self.repo, self.fout)