Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ project uses [semantic versioning][semver].

### Added

- **An Explorer right-click entry: `offloader shell --install`.** Adds "Offload
this card" to a drive's context menu and "Offload this folder" to a
directory's, each opening the app with that path already in the source field.
Written under `HKEY_CURRENT_USER`, so it needs no administrator and touches
no other account, and removed again by `--uninstall`. Windows 11 lists
registry verbs under "Show more options", which the command says rather than
leaving the operator hunting a menu that looks like it failed to install.
The command passes `"%V\."`, not `"%V"`: a drive root expands to `E:\`, and
Windows argument parsing reads `\"` as an escaped quote, so the app would have
received `E:"` and opened without selecting the card.
- **An icon, drawn rather than shipped.** The filmstrip from the PDF header,
rendered to a multi-size `.ico` (16 to 256, simplifying as it shrinks) with
`zlib` and `struct` — no Pillow, no new dependency and no binary artwork in
the repository. The desktop app now uses the same mark as its window icon,
built in memory, so the shell entry, the window and the report header finally
agree on what this tool looks like.
- **A stall is reported instead of looking like a slow link.** A hung network
handle raises nothing — it just stops returning bytes — so nothing could be
retried and the job sat at a stale throughput figure. Source reads are now
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pip install -e ".[dev]"
`ffmpeg` and `ffprobe` on `PATH` are optional — the suite runs without them.

```sh
pytest # 1358 tests, about 20s
pytest # 1400 tests, about 20s
pytest --fuzz # property tests at 3000 examples each, about 3 min
ruff check src tests
pytest --cov=offloader --cov-report=term-missing
Expand Down
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ offloader verify D:\video\080426\A001
| `report` | regenerate paperwork for an existing tree, copying nothing |
| `info` | show tool and environment status |
| `gui` | launch the desktop app (also `offloader-gui`) |
| `shell` | add or remove the Explorer right-click entry (Windows) |

### `offload` and `report`

Expand Down Expand Up @@ -266,6 +267,27 @@ hashes, which is the only check that catches a rename or a moved file, every
file involved still hashes exactly as recorded. See
[`docs/ascmhl.md`](docs/ascmhl.md#directory-hashes).

### `shell` — the Explorer right-click entry

```sh
offloader shell --install # add it, and write the icon it uses
offloader shell # say whether it is installed
offloader shell --uninstall # remove it
```

Adds **Offload this card** to a drive's context menu and **Offload this folder**
to a directory's, both opening the desktop app with that path already in the
source field. Everything goes under `HKEY_CURRENT_USER`, so it needs no
administrator and affects no other account.

The icon is the same filmstrip the PDF header draws, rendered to a multi-size
`.ico` at install time rather than shipped — the repository carries no binary
artwork.

Windows 11 builds its short context menu from packaged COM handlers, so a
registry verb like this one appears under **Show more options** (or Shift+F10,
which opens the classic menu directly).

### Verification modes

| Mode | What it does | Catches |
Expand Down Expand Up @@ -638,13 +660,13 @@ Full verification only when every present destination was hashed.

```sh
pip install -e ".[dev]"
pytest # 1358 tests, ~20s
pytest # 1400 tests, ~20s
pytest --fuzz # same suite, 3000 examples per property (~3 min)
ruff check src tests
pytest --cov=offloader --cov-report=term-missing
```

1358 tests at 88% line coverage. They cover formatting against the reference's
1400 tests at 88% line coverage. They cover formatting against the reference's
exact strings, checksum vectors and streaming equivalence, copy/verify
behaviour including simulated destination corruption, pause/resume/cancel
concurrency, retry discrimination, BRAW container parsing, ffprobe parsing,
Expand Down
42 changes: 41 additions & 1 deletion src/offloader/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ def build_parser() -> argparse.ArgumentParser:

sub.add_parser("info", help="show tool and environment status")
sub.add_parser("gui", help="launch the desktop interface")

shell = sub.add_parser(
"shell", help="manage the Explorer right-click entry (Windows)")
shell.add_argument("--install", action="store_true",
help="add 'Offload this card' to the context menu for "
"drives and folders, and write the icon it uses")
shell.add_argument("--uninstall", action="store_true",
help="remove the context-menu entry")
return parser


Expand Down Expand Up @@ -724,11 +732,43 @@ def cmd_gui(_args: argparse.Namespace) -> int:
return gui_main([sys.argv[0]])


def cmd_shell(args: argparse.Namespace) -> int:
from . import shellicon, shellmenu

if args.install and args.uninstall:
print("error: --install and --uninstall are opposites", file=sys.stderr)
return 2

if args.uninstall:
removed = shellmenu.uninstall()
print("Context-menu entry removed." if removed
else "Nothing to remove; the entry was not installed.")
return 0

if args.install:
icon = shellicon.write()
for entry in shellmenu.install(icon):
print(f" {entry.label} (on right-clicking a {entry.applies_to})")
print(f"\nIcon written to {icon}")
print(f"Runs: {shellmenu.launcher()}")
# Said plainly: Windows 11's short menu is built from packaged COM
# handlers, so an operator looking only there concludes this failed.
print("\nWindows 11 lists registry verbs under 'Show more options' "
"(or Shift+F10 for the classic menu directly).")
return 0

print(f"Context-menu entry: {'installed' if shellmenu.installed() else 'not installed'}")
print(" offloader shell --install add it")
print(" offloader shell --uninstall remove it")
return 0


def main(argv: list[str] | None = None) -> int:
args = build_parser().parse_args(argv)
handlers = {"offload": cmd_offload, "report": cmd_report,
"verify": cmd_verify, "info": cmd_info, "gui": cmd_gui,
"resolve": cmd_resolve, "control": cmd_control}
"resolve": cmd_resolve, "control": cmd_control,
"shell": cmd_shell}
try:
return handlers[args.command](args)
except KeyboardInterrupt:
Expand Down
48 changes: 46 additions & 2 deletions src/offloader/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,43 @@
from __future__ import annotations

import sys
from pathlib import Path

from .. import PRODUCT_NAME, __version__


def _app_icon():
"""The same filmstrip the shell entry and the PDF header use.

Built in memory rather than read from a file: the mark is drawn by
`shellicon`, so launching the app does not need to have written it to disk
first. Only the small sizes — the 256 costs a per-pixel Python loop for
something no title bar will show.
"""
from PySide6.QtGui import QIcon, QPixmap

from .. import shellicon

icon = QIcon()
for size in (16, 32, 48):
pixmap = QPixmap()
pixmap.loadFromData(shellicon.png_at(size), "PNG")
icon.addPixmap(pixmap)
return icon


def clean_path_arg(arg: str) -> str:
"""Undo the `\\.` the Explorer entry appends to the clicked path.

The entry passes `"%V\\."` so a drive root's trailing backslash cannot
escape the closing quote. `E:\\.` already means `E:\\` to Windows, but
the suffix is dropped explicitly so the result does not depend on that.
"""
if arg.endswith(("\\.", "/.")) and len(arg) > 2:
return arg[:-1]
return arg


def main(argv: list[str] | None = None) -> int:
try:
from PySide6.QtWidgets import QApplication
Expand All @@ -21,13 +54,24 @@ def main(argv: list[str] | None = None) -> int:
from . import theme
from .main_window import MainWindow

app = QApplication(argv if argv is not None else sys.argv)
args = list(argv if argv is not None else sys.argv)
# A single trailing path is a source to start from, which is what the
# Explorer context-menu entry passes. Anything Qt wants is left for it.
source: Path | None = None
if len(args) > 1 and not args[-1].startswith("-"):
candidate = Path(clean_path_arg(args[-1]))
if candidate.exists():
source = candidate
args = args[:-1]

app = QApplication(args)
app.setApplicationName(PRODUCT_NAME)
app.setApplicationVersion(__version__)
app.setOrganizationName(PRODUCT_NAME)
app.setWindowIcon(_app_icon())
theme.apply(app)

window = MainWindow()
window = MainWindow(source)
window.show()
return app.exec()

Expand Down
8 changes: 7 additions & 1 deletion src/offloader/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def _bullets(lines: list[str], limit: int = 12) -> str:


class MainWindow(QMainWindow):
def __init__(self) -> None:
def __init__(self, source: Path | None = None) -> None:
"""`source` pre-fills the source field — what the Explorer context-menu
entry passes, so a right-clicked card arrives already selected."""
super().__init__()
self.setWindowTitle(f"{PRODUCT_NAME} {__version__}")
self.resize(1280, 840)
Expand Down Expand Up @@ -133,6 +135,10 @@ def __init__(self) -> None:
self._set_mode(1 if self.settings.get("mode") == "simple" else 0)
self.drives.start()

# Last, so the panels it fills are built and the mode is settled.
if source is not None:
self._set_source(Path(source))

# ---------------------------------------------------------------- chrome
def _build_menu(self) -> None:
job_menu = self.menuBar().addMenu("&Job")
Expand Down
Loading
Loading