Entferne rebuild-cache da es Konflikte gibt

This commit is contained in:
Akamaru
2025-10-23 16:03:22 +02:00
parent 1d29671ed2
commit b5eba412ad
3 changed files with 5 additions and 62 deletions

6
cli.py
View File

@@ -93,11 +93,6 @@ def parse_args(args):
"products/bundle download page. Can set multiple"
),
)
parser.add_argument(
"--rebuild-cache",
action="store_true",
help="Rebuild cache by checking all existing files in library",
)
return parser.parse_args(args)
@@ -118,5 +113,4 @@ def cli():
purchase_keys=cli_args.keys,
trove=cli_args.trove,
update=cli_args.update,
rebuild_cache=cli_args.rebuild_cache,
).start()

View File

@@ -34,7 +34,6 @@ class DownloadLibrary:
purchase_keys=None,
trove=False,
update=False,
rebuild_cache=False,
):
self.library_path = library_path
self.progress_bar = progress_bar
@@ -53,7 +52,6 @@ class DownloadLibrary:
self.purchase_keys = purchase_keys
self.trove = trove
self.update = update
self.rebuild_cache = rebuild_cache
self.session = requests.Session()
if cookie_path:
@@ -73,12 +71,6 @@ class DownloadLibrary:
def start(self):
self.cache_file = os.path.join(self.library_path, ".cache.json")
self.cache_data = self._load_cache_data(self.cache_file)
# If rebuild_cache is requested, clear the cache
if self.rebuild_cache:
logger.warning("Rebuilding cache from existing files...")
self.cache_data = {}
self.purchase_keys = (
self.purchase_keys if self.purchase_keys else self._get_purchase_keys()
)
@@ -150,31 +142,19 @@ class DownloadLibrary:
# Do not care about checking for updates at this time
continue
# Determine file paths
product_folder = os.path.join(self.library_path, "Humble Trove", title)
local_filename = os.path.join(product_folder, web_name)
# If no cache entry exists, check if file physically exists
if cache_file_info == {}:
existing_file_mtime = self._file_exists_in_library(local_filename)
if existing_file_mtime is not None and self.update is not True:
logger.info(
"Trove file exists but not in cache, adding to cache: {filename}".format(
filename=web_name
)
)
# Add to cache with current file info
self._update_cache_data(cache_file_key, file_info)
continue
if file_info["uploaded_at"] != cache_file_info.get(
"uploaded_at"
) and file_info["md5"] != cache_file_info.get("md5"):
product_folder = os.path.join(self.library_path, "Humble Trove", title)
# Create directory to save the files to
try:
os.makedirs(product_folder)
except OSError:
pass
local_filename = os.path.join(
product_folder,
web_name,
)
signed_url = self._get_trove_download_url(
download["machine_name"],
web_name,
@@ -472,21 +452,6 @@ class DownloadLibrary:
# Do not care about checking for updates at this time
raise FileExistsError
# If no cache entry exists, check if file physically exists
local_file = os.path.join(local_folder, local_filename)
if cache_file_info == {}:
existing_file_mtime = self._file_exists_in_library(local_file)
if existing_file_mtime is not None and self.update is not True:
logger.info(
"File exists but not in cache, adding to cache: {filename}".format(
filename=local_filename
)
)
# Add to cache with file modification time
file_info = {"url_last_modified": existing_file_mtime}
self._update_cache_data(cache_file_key, file_info)
raise FileExistsError
try:
remote_file_r = self.session.get(remote_file, stream=True)
except Exception:
@@ -635,16 +600,6 @@ class DownloadLibrary:
return cache_data
def _file_exists_in_library(self, local_file):
"""
Check if a file exists in the library and return its modification time
formatted as HTTP Last-Modified header if it does.
"""
if os.path.isfile(local_file):
mtime = os.path.getmtime(local_file)
return time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(mtime))
return None
def _get_purchase_keys(self):
try:
library_r = self.session.get("https://www.humblebundle.com/home/library")

View File

@@ -102,11 +102,6 @@ def parse_args(args):
"products/bundle download page. Can set multiple"
),
)
parser.add_argument(
"--rebuild-cache",
action="store_true",
help="Rebuild cache by checking all existing files in library",
)
return parser.parse_args(args)
@@ -127,7 +122,6 @@ def main():
purchase_keys=cli_args.keys,
trove=cli_args.trove,
update=cli_args.update,
rebuild_cache=cli_args.rebuild_cache,
).start()