fix: Add condition to avoid breaking the add command

This commit is contained in:
Cristian 2020-07-29 11:53:49 -05:00
parent c073ea141d
commit 3afb2401bc
2 changed files with 7 additions and 4 deletions

View file

@ -123,7 +123,7 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
@enforce_types
def archive_links(links: List[Link], overwrite: bool=False, methods: Optional[Iterable[str]]=None, out_dir: Optional[str]=None, skip_index: bool=False) -> List[Link]:
def archive_links(links: List[Link], overwrite: bool=False, methods: Optional[Iterable[str]]=None, out_dir: Optional[str]=None, skip_index: bool=False, oneshot: bool=False) -> List[Link]:
if not links:
return []
@ -132,8 +132,11 @@ def archive_links(links: List[Link], overwrite: bool=False, methods: Optional[It
link: Link = links[0]
try:
for idx, link in enumerate(links):
if oneshot:
link_out_dir = out_dir or link.link_dir
archive_link(link, overwrite=overwrite, methods=methods, link_out_dir=out_dir, skip_index=skip_index)
else:
link_out_dir = link.link_dir
archive_link(link, overwrite=overwrite, methods=methods, out_dir=link_out_dir, skip_index=skip_index)
except KeyboardInterrupt:
log_archiving_paused(len(links), idx, link.timestamp)
raise SystemExit(0)

View file

@ -498,7 +498,7 @@ def status(out_dir: str=OUTPUT_DIR) -> None:
def oneshot(url: str, out_dir: str=OUTPUT_DIR):
oneshot_links, _ = parse_links_memory([url])
oneshot_links, _ = dedupe_links([], oneshot_links)
archive_links(oneshot_links, out_dir=out_dir, skip_index=True)
archive_links(oneshot_links, out_dir=out_dir, skip_index=True, oneshot=True)
return oneshot_links
@enforce_types