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

Closed
opened 2026-03-15 01:39:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ArchiveBox/ArchiveBox/pull/1154
Author: @sissbruecker
Created: 5/29/2023
Status: Merged
Merged: 5/31/2023
Merged by: @pirate

Base: devHead: fix/oneshot_exit_code


📝 Commits (2)

  • 40c1225 fix: make oneshot command return successful exist code
  • 7bf4f40 just use out_dir

📊 Changes

2 files changed (+34 additions, -2 deletions)

View changed files

📝 archivebox/extractors/__init__.py (+1 -1)
📝 tests/test_oneshot.py (+33 -1)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ArchiveBox/ArchiveBox/pull/1154 **Author:** [@sissbruecker](https://github.com/sissbruecker) **Created:** 5/29/2023 **Status:** ✅ Merged **Merged:** 5/31/2023 **Merged by:** [@pirate](https://github.com/pirate) **Base:** `dev` ← **Head:** `fix/oneshot_exit_code` --- ### 📝 Commits (2) - [`40c1225`](https://github.com/ArchiveBox/ArchiveBox/commit/40c122515a6b67f899ef9bc5e0b2380447ee8024) fix: make oneshot command return successful exist code - [`7bf4f40`](https://github.com/ArchiveBox/ArchiveBox/commit/7bf4f40da02d8e75420197b5315d2dc88ca3f9ee) just use out_dir ### 📊 Changes **2 files changed** (+34 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `archivebox/extractors/__init__.py` (+1 -1) 📝 `tests/test_oneshot.py` (+33 -1) </details> ### 📄 Description <!-- 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-15 01:39:35 +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#4345
No description provided.