mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 10:21:19 +02:00
fix overwrite issue #344
This commit is contained in:
parent
eb5b93d654
commit
09bb8460f6
@ -74,23 +74,22 @@ class Doujinshi(object):
|
||||
|
||||
def check_if_need_download(self, options):
|
||||
base_path = os.path.join(self.downloader.path, self.filename)
|
||||
file_ext = None
|
||||
|
||||
# regenerate, re-download
|
||||
if options.regenerate:
|
||||
return True
|
||||
|
||||
# detect file extensions
|
||||
if options.is_pdf:
|
||||
file_ext = 'pdf'
|
||||
elif options.is_cbz:
|
||||
file_ext = 'cbz'
|
||||
|
||||
# pdf or cbz file exists, skip re-download
|
||||
# doujinshi directory may not exist b/c of --rm-origin-dir option set.
|
||||
# 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}'):
|
||||
ret_pdf = ret_cbz = None
|
||||
if options.is_pdf:
|
||||
ret_pdf = os.path.exists(f'{base_path}.pdf') or os.path.exists(f'{base_path}/{self.filename}.pdf')
|
||||
|
||||
if options.is_cbz:
|
||||
ret_cbz = os.path.exists(f'{base_path}.cbz') or os.path.exists(f'{base_path}/{self.filename}.cbz')
|
||||
|
||||
if all(filter(lambda s: s is not None, [ret_cbz, ret_pdf])):
|
||||
return False
|
||||
|
||||
# doujinshi directory doesn't exist, re-download
|
||||
|
Loading…
x
Reference in New Issue
Block a user