mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 18:31:24 +02:00
regression: pdf/cbz file already exists, but origin files are downloaded anyways.
- call download with `--cbz --rm-origin-dir`, and run command twice. - user should pass `--regenerate` option to get back origin dir.
This commit is contained in:
parent
98a66a3cb0
commit
cb6cf6df1a
@ -74,26 +74,28 @@ class Doujinshi(object):
|
|||||||
|
|
||||||
def check_if_need_download(self, options):
|
def check_if_need_download(self, options):
|
||||||
base_path = os.path.join(self.downloader.path, self.filename)
|
base_path = os.path.join(self.downloader.path, self.filename)
|
||||||
|
file_ext = None
|
||||||
|
|
||||||
# doujinshi directory is not exist, we need to download definitely
|
# regenerate, re-download
|
||||||
if not (os.path.exists(base_path) and os.path.isdir(base_path)):
|
|
||||||
return True
|
|
||||||
|
|
||||||
# regenerate, we need to re-download from nhentai
|
|
||||||
if options.regenerate:
|
if options.regenerate:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# detect file extensions
|
||||||
if options.is_pdf:
|
if options.is_pdf:
|
||||||
file_ext = 'pdf'
|
file_ext = 'pdf'
|
||||||
elif options.is_cbz:
|
elif options.is_cbz:
|
||||||
file_ext = 'cbz'
|
file_ext = 'cbz'
|
||||||
else:
|
|
||||||
# re-download
|
|
||||||
return True
|
|
||||||
|
|
||||||
# pdf or cbz file exists, we needn't to re-download it
|
# pdf or cbz file exists, skip re-download
|
||||||
if os.path.exists(f'{base_path}.{file_ext}') or os.path.exists(f'{base_path}/{self.filename}.{file_ext}'):
|
# doujinshi directory may not exist b/c of --rm-origin-dir option set.
|
||||||
return False
|
# user should pass --regenerate option to get back origin dir.
|
||||||
|
if file_ext is not None:
|
||||||
|
if os.path.exists(f'{base_path}.{file_ext}') or os.path.exists(f'{base_path}/{self.filename}.{file_ext}'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
# doujinshi directory doesn't exist, re-download
|
||||||
|
if not (os.path.exists(base_path) and os.path.isdir(base_path)):
|
||||||
|
return True
|
||||||
|
|
||||||
# fallback
|
# fallback
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user