fallback to reading binaries from filesystem when theres no db

This commit is contained in:
Nick Sweeting 2024-10-04 01:00:09 -07:00
parent 8336c997a1
commit f321d25f4c
No known key found for this signature in database
2 changed files with 15 additions and 10 deletions

View file

@ -78,9 +78,14 @@ class BaseBinary(BaseHook, Binary):
self.symlink_to_lib(binary=binary, bin_dir=CONSTANTS.LIB_BIN_DIR) self.symlink_to_lib(binary=binary, bin_dir=CONSTANTS.LIB_BIN_DIR)
else: else:
# get cached binary from db # get cached binary from db
from machine.models import InstalledBinary try:
installed_binary = InstalledBinary.objects.get_from_db_or_cache(self) from machine.models import InstalledBinary
binary = InstalledBinary.load_from_db(installed_binary) installed_binary = InstalledBinary.objects.get_from_db_or_cache(self)
binary = InstalledBinary.load_from_db(installed_binary)
except Exception:
# maybe we are not in a DATA dir so there is no db, fallback to reading from fs
# (e.g. when archivebox version is run outside of a DATA dir)
binary = super().load(**kwargs)
return binary return binary
@validate_call @validate_call

View file

@ -154,14 +154,14 @@ def run_subcommand(subcommand: str,
subcommand_args = subcommand_args or [] subcommand_args = subcommand_args or []
from archivebox.config.legacy import setup_django
cmd_requires_db = subcommand in archive_cmds
init_pending = '--init' in subcommand_args or '--quick-init' in subcommand_args
setup_django(in_memory_db=subcommand in fake_db, check_db=cmd_requires_db and not init_pending)
if subcommand not in meta_cmds: if subcommand not in meta_cmds:
from archivebox.config.legacy import setup_django
cmd_requires_db = subcommand in archive_cmds
init_pending = '--init' in subcommand_args or '--quick-init' in subcommand_args
setup_django(in_memory_db=subcommand in fake_db, check_db=cmd_requires_db and not init_pending)
if cmd_requires_db: if cmd_requires_db:
check_migrations() check_migrations()