Browse Source

[fb] Fix appending to existing file if upload is interrupted

krish 10 years ago
parent
commit
0ad436fbd6
1 changed files with 6 additions and 5 deletions
  1. 6 5
      desktop/libs/hadoop/src/hadoop/fs/upload.py

+ 6 - 5
desktop/libs/hadoop/src/hadoop/fs/upload.py

@@ -67,11 +67,12 @@ class HDFStemporaryUploadedFile(object):
 
     # We want to set the user to be the user doing the upload
     self._fs.setuser(request.user.username)
-    try:
-      self._path = self._fs.mkswap(name, suffix='tmp', basedir=destination)
-      self._file = self._fs.open(self._path, 'w')
-    except WebHdfsException, e:
-      raise e
+    self._path = self._fs.mkswap(name, suffix='tmp', basedir=destination)
+
+    if self._fs.exists(self._path):
+      self._fs._delete(self._path)
+    self._file = self._fs.open(self._path, 'w')
+
     self._do_cleanup = True
 
   def __del__(self):