Skip to content

Bulk asynchronous downloader for multiple file hosts

remove need for prev hash it is redundant and make all requirements passed to remove

datawhores7c1be97206a6
diff --git a/cyberdrop_dl/clients/hash_client.py b/cyberdrop_dl/clients/hash_client.py
index c27ea3aca..867bb3dd5 100644
--- a/cyberdrop_dl/clients/hash_client.py
+++ b/cyberdrop_dl/clients/hash_client.py
@@ -27,7 +27,6 @@ class HashClient:
def __init__(self,manager):
self.manager=manager
self.hashes=defaultdict(lambda:None)
- self.prev_hashes=None
@asynccontextmanager
async def _manager_context(self):
@@ -35,7 +34,7 @@ class HashClient:
yield
await self.manager.close()
async def startup(self):
- self.prev_hashes=set(await self.manager.db_manager.hash_table.get_all_unique_hashes())
+ pass
@@ -135,15 +134,15 @@ class HashClient:
await self.manager.db_manager.hash_table.get_files_with_hash_matches(hash, size)))
# Filter out files with the same path as any file in other_files
- filtered_matches = [match for match in all_matches if str(match) not in other_files]
+ other_matches = [match for match in all_matches if str(match) not in other_files]
#Filter files based on if the file exists
- filtered_matches = list(filter(lambda x: x.exists(),filtered_matches ))
+ existing_other_matches = list(filter(lambda x: x.exists(),other_matches ))
#what do do with prev matches and current file
- if len(filtered_matches) == 0:
+ if len(existing_other_matches) == 0:
pass
elif not self.manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_prev_download']:
- for ele in filtered_matches:
+ for ele in existing_other_matches:
if not ele.exists():
continue
try:
@@ -154,7 +153,7 @@ class HashClient:
continue
#delete all prev match except for one
else:
- for ele in filtered_matches[1:]:
+ for ele in existing_other_matches[1:]:
if not ele.exists():
continue
try:
@@ -165,10 +164,10 @@ class HashClient:
continue
if self.manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_new_download']:
continue
- elif hash not in self.prev_hashes:
- continue
elif not self.manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_prev_download']:
continue
+ elif len(other_matches)==0:
+ continue
elif selected_file in self.manager.path_manager.prev_downloads_paths:
continue
else:
diff --git a/docs/reference/configuration-options/global-settings.md b/docs/reference/configuration-options/global-settings.md
index c839c12e8..4aa87f14a 100644
--- a/docs/reference/configuration-options/global-settings.md
+++ b/docs/reference/configuration-options/global-settings.md
@@ -145,19 +145,14 @@ With this set as True. Files can be hash after each download, rather than all to
If enabled for each hash and size match one download will be kept on the system.
If disabled all current files will be deleted if the following is all true
-- This is not the first time the hash has appeared in the filesystem
- The file did not exist on the filesystem prior to the current run
-
-or
-
- keep prev_download is set to true, this ignores if file exists on the filesystem or not
-
+- A file must be in the database with a matching hash. This excludes files downloaded and skipped for already existing
* keep\_prev\_download
prev downloads are files that are match with the list of files to be processed. A previous download is one not processed by the urls given and that exists in the database for the same hash and file size
If enabled then at least one existing previous download will be kept on system.
-
If not enabled all previous downloads will be deleted
</details>