aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2011-01-12 20:21:43 +0100
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2011-01-12 20:21:43 +0100
commit8cc42e7c1a5bc05a6ca753c0f92732c04ac48ab7 (patch)
tree8e0b1b38e86e0eb2cbc63f196cfae1a6097db698
parent1987c2325a9764e24104fa8da23b467a5e33cf49 (diff)
Fix "unable to rename file" Windows error (closes #56)
-rwxr-xr-xyoutube-dl6
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube-dl b/youtube-dl
index 13d42765b..c49c1b064 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -429,6 +429,11 @@ class FileDownloader(object):
return filename
return filename + u'.part'
+ def undo_temp_name(self, filename):
+ if filename.endswith(u'.part'):
+ return filename[:-len(u'.part')]
+ return filename
+
def try_rename(self, old_filename, new_filename):
try:
if old_filename == new_filename:
@@ -698,6 +703,7 @@ class FileDownloader(object):
if stream is None:
try:
(stream, tmpfilename) = sanitize_open(tmpfilename, open_mode)
+ filename = self.undo_temp_name(tmpfilename)
self.report_destination(filename)
except (OSError, IOError), err:
self.trouble(u'ERROR: unable to open for writing: %s' % str(err))