aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-12-09 19:33:04 +0100
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-12-09 19:33:04 +0100
commit7d950ca1d6543d51d066eaceb9ea1d5ac96d92f4 (patch)
treef1b6ebcb8a65938d288da8a8401ac1b546dc5831
parentd157d2597a5fe99db60304fe1e89523de78b7981 (diff)
Improve temporary filename handling of special cases
-rwxr-xr-xyoutube-dl6
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube-dl b/youtube-dl
index 415cf7073..64c590fbf 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -238,7 +238,9 @@ class FileDownloader(object):
@staticmethod
def temp_name(filename):
"""Returns a temporary filename for the given filename."""
- return filename + '.part'
+ if filename == u'-' or (os.path.exists(filename) and not os.path.isfile(filename)):
+ return filename
+ return filename + u'.part'
@staticmethod
def format_bytes(bytes):
@@ -361,6 +363,8 @@ class FileDownloader(object):
def try_rename(self, old_filename, new_filename):
try:
+ if old_filename == new_filename:
+ return
os.rename(old_filename, new_filename)
except (IOError, OSError), err:
self.trouble(u'ERROR: unable to rename file')