diff options
-rwxr-xr-x | lorry | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -30,6 +30,12 @@ __version__ = '0.0' lorry_path = os.path.realpath(__file__) + +def file_missing_or_empty(filename): + ''' A more comprehensive alternative to os.path.exists(). ''' + return (not os.path.isfile(filename)) or (os.path.getsize(filename) <= 0) + + def quote_url(url): ''' Convert URIs to strings that only contain digits, letters, % and _. @@ -475,7 +481,7 @@ class Lorry(cliapp.Application): basename = os.path.basename(url_path) tardest = os.path.join(dirname, basename) self.progress('.. checking if we need to fetch %s' % basename) - if not os.path.exists(tardest): + if file_missing_or_empty(tardest): self.progress('.. attempting to fetch.') try: with open(tardest, 'w') as tarfile: |