[PR #1154] fix: make oneshot command return successful exit code #2839

Closed
opened 2026-03-01 18:00:55 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/ArchiveBox/ArchiveBox/pull/1154

State: closed
Merged: Yes


Summary

While the oneshot command correctly creates output files, the command itself returns an exit code, and logs the following error:

    ! Failed to archive link: FileNotFoundError: [Errno 2] No such file or directory: '<archivebox_location>/archive/1685300775.342935'
Traceback (most recent call last):
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/bin/archivebox", line 8, in <module>
    sys.exit(main())
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 140, in main
    run_subcommand(
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 80, in run_subcommand
    module.main(args=subcommand_args, stdin=stdin, pwd=pwd)    # type: ignore
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/cli/archivebox_oneshot.py", line 65, in main
    oneshot(
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/util.py", line 114, in typechecked_function
    return func(*args, **kwargs)
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/main.py", line 548, in oneshot
    archive_link(oneshot_link[0], out_dir=out_dir, methods=methods)
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/util.py", line 114, in typechecked_function
    return func(*args, **kwargs)
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/extractors/__init__.py", line 146, in archive_link
    log_link_archiving_finished(link, link.link_dir, is_new, stats, start_ts)
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/logging_util.py", line 396, in log_link_archiving_finished
    size = get_dir_size(link_dir)
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/util.py", line 114, in typechecked_function
    return func(*args, **kwargs)
  File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/system.py", line 131, in get_dir_size
    for entry in os.scandir(path):
FileNotFoundError: [Errno 2] No such file or directory: '<archivebox_location>/archive/1685300775.342935'

It fails in the log_link_archiving_finished function, where it tries to log information about the link's directory within the archive, which doesn't exist because the oneshot command writes its output into a custom output dir.

This change updates the call to that function to alternatively pass the custom output dir if it has been specified.

I have seen an issue that mentions that the oneshot command is considered deprecated, still I would find it useful and this fix seems to have low impact.

Related issues

No related issue.

Changes these areas

  • Bugfixes
  • Feature behavior
  • Command line interface
  • Configuration options
  • Internal architecture
  • Snapshot data layout on disk
**Original Pull Request:** https://github.com/ArchiveBox/ArchiveBox/pull/1154 **State:** closed **Merged:** Yes --- <!-- IMPORTANT: Do not submit PRs with only formatting / PEP8 / line length changes. --> # Summary While the oneshot command correctly creates output files, the command itself returns an exit code, and logs the following error: ``` ! Failed to archive link: FileNotFoundError: [Errno 2] No such file or directory: '<archivebox_location>/archive/1685300775.342935' Traceback (most recent call last): File "/Users/sascha/dev/projects/linkding/venv/archivebox/bin/archivebox", line 8, in <module> sys.exit(main()) File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 140, in main run_subcommand( File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/cli/__init__.py", line 80, in run_subcommand module.main(args=subcommand_args, stdin=stdin, pwd=pwd) # type: ignore File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/cli/archivebox_oneshot.py", line 65, in main oneshot( File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/util.py", line 114, in typechecked_function return func(*args, **kwargs) File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/main.py", line 548, in oneshot archive_link(oneshot_link[0], out_dir=out_dir, methods=methods) File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/util.py", line 114, in typechecked_function return func(*args, **kwargs) File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/extractors/__init__.py", line 146, in archive_link log_link_archiving_finished(link, link.link_dir, is_new, stats, start_ts) File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/logging_util.py", line 396, in log_link_archiving_finished size = get_dir_size(link_dir) File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/util.py", line 114, in typechecked_function return func(*args, **kwargs) File "/Users/sascha/dev/projects/linkding/venv/archivebox/lib/python3.10/site-packages/archivebox/system.py", line 131, in get_dir_size for entry in os.scandir(path): FileNotFoundError: [Errno 2] No such file or directory: '<archivebox_location>/archive/1685300775.342935' ``` It fails in the `log_link_archiving_finished` function, where it tries to log information about the link's directory within the archive, which doesn't exist because the oneshot command writes its output into a custom output dir. This change updates the call to that function to alternatively pass the custom output dir if it has been specified. I have seen an issue that mentions that the oneshot command is considered deprecated, still I would find it useful and this fix seems to have low impact. # Related issues No related issue. # Changes these areas - [x] Bugfixes - [ ] Feature behavior - [ ] Command line interface - [ ] Configuration options - [ ] Internal architecture - [ ] Snapshot data layout on disk
kerem 2026-03-01 18:00:55 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ArchiveBox#2839
No description provided.