Skip to content

Commit a0f817c

Browse files
committed
now correctly detects already downloaded files
- closes issue #18 - also, clarified/simplified what happens when no suitable downloads were found during update
1 parent b224ea2 commit a0f817c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

e621dl.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113

114114
else:
115115
will_download = 0
116-
116+
117117
# there were uploads. determine should any be downloaded
118118
LOG.info(str(len(potential_downloads)) + ' new uploads for: ' + line)
119119
current = 0
@@ -131,7 +131,7 @@
131131
LOG.debug(current + 'skipped (previously downloaded)')
132132

133133
# skip if already in download directory
134-
elif os.path.isfile(filename):
134+
elif os.path.isfile(CONFIG['download_directory'] + filename):
135135
links_on_disk += 1
136136
LOG.debug(current + 'skipped (already in downloads directory')
137137

@@ -151,10 +151,13 @@
151151
'\t(cached: ' + str(links_in_cache) + \
152152
', existing: ' + str(links_on_disk) + ')\n')
153153

154-
print ''
155-
LOG.info('starting download of ' + str(len(URL_AND_NAME_LIST)) + ' files')
156154
if URL_AND_NAME_LIST:
157-
multi_download(URL_AND_NAME_LIST, CONFIG['parallel_downloads'])
155+
print ''
156+
LOG.info('starting download of ' + str(len(URL_AND_NAME_LIST)) + ' files')
157+
multi_download(URL_AND_NAME_LIST, CONFIG['parallel_downloads'])
158+
else:
159+
LOG.info('nothing to download')
160+
158161

159162
##############################################################################
160163
# WRAP-UP
@@ -163,7 +166,8 @@
163166
# - set last run to yesterday (see FAQ for why it isn't today)
164167
##############################################################################
165168
pickle.dump(CACHE, open('.cache', 'wb'), pickle.HIGHEST_PROTOCOL)
166-
LOG.info('successfully downloaded ' + str(TOTAL_DOWNLOADS) + ' files')
169+
if URL_AND_NAME_LIST:
170+
LOG.info('successfully downloaded ' + str(TOTAL_DOWNLOADS) + ' files')
167171
YESTERDAY = datetime.date.fromordinal(datetime.date.today().toordinal()-1)
168172
CONFIG['last_run'] = YESTERDAY.strftime(default.DATETIME_FMT)
169173

0 commit comments

Comments
 (0)