mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-10-31 09:39:34 +01:00 
			
		
		
		
	fix overwrite issue #344
This commit is contained in:
		| @@ -74,24 +74,23 @@ 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 |  | ||||||
|  |  | ||||||
|         # regenerate, re-download |         # regenerate, re-download | ||||||
|         if options.regenerate: |         if options.regenerate: | ||||||
|             return True |             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 |         # pdf or cbz file exists, skip re-download | ||||||
|         # doujinshi directory may not exist b/c of --rm-origin-dir option set. |         # doujinshi directory may not exist b/c of --rm-origin-dir option set. | ||||||
|         # user should pass --regenerate option to get back origin dir. |         # user should pass --regenerate option to get back origin dir. | ||||||
|         if file_ext is not None: |         ret_pdf = ret_cbz = None | ||||||
|             if os.path.exists(f'{base_path}.{file_ext}') or os.path.exists(f'{base_path}/{self.filename}.{file_ext}'): |         if options.is_pdf: | ||||||
|                 return False |             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 |         # doujinshi directory doesn't exist, re-download | ||||||
|         if not (os.path.exists(base_path) and os.path.isdir(base_path)): |         if not (os.path.exists(base_path) and os.path.isdir(base_path)): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user