refactor: Remove get_empty_snapshot queryset function and generate it directly
This commit is contained in:
parent
81d766aba1
commit
a28547cbca
2 changed files with 4 additions and 9 deletions
|
@ -243,12 +243,6 @@ def write_main_index(links: List[Link], out_dir: Path=OUTPUT_DIR) -> None:
|
||||||
|
|
||||||
log_indexing_process_finished()
|
log_indexing_process_finished()
|
||||||
|
|
||||||
@enforce_types
|
|
||||||
def get_empty_snapshot_queryset(out_dir: Path=OUTPUT_DIR):
|
|
||||||
setup_django(out_dir, check_db=True)
|
|
||||||
from core.models import Snapshot
|
|
||||||
return Snapshot.objects.none()
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
def load_main_index(out_dir: Path=OUTPUT_DIR, warn: bool=True) -> List[Link]:
|
def load_main_index(out_dir: Path=OUTPUT_DIR, warn: bool=True) -> List[Link]:
|
||||||
"""parse and load existing index with any new links from import_path merged in"""
|
"""parse and load existing index with any new links from import_path merged in"""
|
||||||
|
@ -390,8 +384,9 @@ def search_filter(snapshots: QuerySet, filter_patterns: List[str], filter_type:
|
||||||
color='red',
|
color='red',
|
||||||
)
|
)
|
||||||
raise SystemExit(2)
|
raise SystemExit(2)
|
||||||
|
from core.models import Snapshot
|
||||||
|
|
||||||
qsearch = get_empty_snapshot_queryset()
|
qsearch = Snapshot.objects.none()
|
||||||
for pattern in filter_patterns:
|
for pattern in filter_patterns:
|
||||||
try:
|
try:
|
||||||
qsearch |= query_search_index(pattern)
|
qsearch |= query_search_index(pattern)
|
||||||
|
|
|
@ -29,7 +29,6 @@ from .util import enforce_types # type: ignore
|
||||||
from .system import get_dir_size, dedupe_cron_jobs, CRON_COMMENT
|
from .system import get_dir_size, dedupe_cron_jobs, CRON_COMMENT
|
||||||
from .index import (
|
from .index import (
|
||||||
load_main_index,
|
load_main_index,
|
||||||
get_empty_snapshot_queryset,
|
|
||||||
parse_links_from_source,
|
parse_links_from_source,
|
||||||
dedupe_links,
|
dedupe_links,
|
||||||
write_main_index,
|
write_main_index,
|
||||||
|
@ -265,6 +264,7 @@ def run(subcommand: str,
|
||||||
@enforce_types
|
@enforce_types
|
||||||
def init(force: bool=False, out_dir: Path=OUTPUT_DIR) -> None:
|
def init(force: bool=False, out_dir: Path=OUTPUT_DIR) -> None:
|
||||||
"""Initialize a new ArchiveBox collection in the current directory"""
|
"""Initialize a new ArchiveBox collection in the current directory"""
|
||||||
|
from core.models import Snapshot
|
||||||
Path(out_dir).mkdir(exist_ok=True)
|
Path(out_dir).mkdir(exist_ok=True)
|
||||||
is_empty = not len(set(os.listdir(out_dir)) - ALLOWED_IN_OUTPUT_DIR)
|
is_empty = not len(set(os.listdir(out_dir)) - ALLOWED_IN_OUTPUT_DIR)
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ def init(force: bool=False, out_dir: Path=OUTPUT_DIR) -> None:
|
||||||
print()
|
print()
|
||||||
print('{green}[*] Collecting links from any existing indexes and archive folders...{reset}'.format(**ANSI))
|
print('{green}[*] Collecting links from any existing indexes and archive folders...{reset}'.format(**ANSI))
|
||||||
|
|
||||||
all_links = get_empty_snapshot_queryset()
|
all_links = Snapshot.objects.none()
|
||||||
pending_links: Dict[str, Link] = {}
|
pending_links: Dict[str, Link] = {}
|
||||||
|
|
||||||
if existing_index:
|
if existing_index:
|
||||||
|
|
Loading…
Reference in a new issue