projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d157d25
)
Improve temporary filename handling of special cases
author
Ricardo Garcia
<sarbalap+freshmeat@gmail.com>
Thu, 9 Dec 2010 18:33:04 +0000
(19:33 +0100)
committer
Ricardo Garcia
<sarbalap+freshmeat@gmail.com>
Thu, 9 Dec 2010 18:33:04 +0000
(19:33 +0100)
youtube-dl
patch
|
blob
|
history
diff --git
a/youtube-dl
b/youtube-dl
index 415cf707379ca7bc667e0900372f9d7884f0675e..64c590fbfc30e954bde63cbde74d55af7997a308 100755
(executable)
--- 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."""
@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):
@staticmethod
def format_bytes(bytes):
@@
-361,6
+363,8
@@
class FileDownloader(object):
def try_rename(self, old_filename, new_filename):
try:
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')
os.rename(old_filename, new_filename)
except (IOError, OSError), err:
self.trouble(u'ERROR: unable to rename file')