Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(wallpapers): one-click download of the 500-piece library from the asset release

rubenluetke10-beepbfbf879bc696
diff --git a/jarvis/ui/web/frontend/src/hooks/useWallpaperLibrary.ts b/jarvis/ui/web/frontend/src/hooks/useWallpaperLibrary.ts
new file mode 100644
index 0000000000..58b36b2b14
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/hooks/useWallpaperLibrary.ts
@@ -0,0 +1,81 @@
+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+
+/**
+ * The library installer, as the server reports it.
+ *
+ * `state` is the machine the download banner renders from: `idle` before
+ * anything happened, `downloading`/`unpacking` while the daemon thread works,
+ * `done` once the catalog is on disk, `error` with a sentence for the owner.
+ */
+export interface LibraryInstallStatus {
+ installed: boolean;
+ state: "idle" | "downloading" | "unpacking" | "done" | "error";
+ receivedBytes: number;
+ totalBytes: number;
+ error: string | null;
+}
+
+const STATUS_URL = "/api/wallpapers/library";
+const STATUS_KEY = ["wallpapers", "library"] as const;
+
+/** True while the server is actively working on the install. */
+export function installRunning(status: LibraryInstallStatus | undefined): boolean {
+ return status?.state === "downloading" || status?.state === "unpacking";
+}
+
+function parse(data: unknown): LibraryInstallStatus | null {
+ const status = data as Partial<LibraryInstallStatus> | null;
+ if (!status || typeof status.state !== "string") return null;
+ return {
+ installed: Boolean(status.installed),
+ state: status.state as LibraryInstallStatus["state"],
+ receivedBytes: typeof status.receivedBytes === "number" ? status.receivedBytes : 0,
+ totalBytes: typeof status.totalBytes === "number" ? status.totalBytes : 0,
+ error: typeof status.error === "string" ? status.error : null,
+ };
+}
+
+/**
+ * The install status, polled only while an install is actually running.
+ *
+ * The 500-piece library is optional content a fresh machine does not have, so
+ * this is what turns the "download it" button into a progress bar. Once the
+ * server reports `done`, the catalog query is refetched and the grid fills in
+ * without a reload.
+ */
+export function useWallpaperLibraryInstall() {
+ const client = useQueryClient();
+
+ const status = useQuery<LibraryInstallStatus | null>({
+ queryKey: STATUS_KEY,
+ queryFn: async () => {
+ const data = await fetch(STATUS_URL)
+ .then((response) => (response.ok ? response.json() : null))
+ .catch(() => null);
+ const parsed = parse(data);
+ // The catalog was fetched once and kept (see useWallpaperCatalog); the
+ // install finishing is the one event that makes it stale.
+ if (parsed?.state === "done") {
+ void client.invalidateQueries({ queryKey: ["wallpapers"], exact: true });
+ }
+ return parsed;
+ },
+ refetchInterval: (query) =>
+ installRunning(query.state.data ?? undefined) ? 500 : false,
+ });
+
+ const start = useMutation<LibraryInstallStatus | null, Error>({
+ mutationFn: async () => {
+ const response = await fetch(`${STATUS_URL}/install`, { method: "POST" });
+ if (!response.ok) {
+ throw new Error("The download could not be started.");
+ }
+ return parse(await response.json());
+ },
+ onSuccess: (data) => {
+ client.setQueryData(STATUS_KEY, data);
+ },
+ });
+
+ return { status, start };
+}
diff --git a/jarvis/ui/web/frontend/src/views/WallpaperView.test.tsx b/jarvis/ui/web/frontend/src/views/WallpaperView.test.tsx
index 68ec59d8a1..304061d8ac 100644
--- a/jarvis/ui/web/frontend/src/views/WallpaperView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/WallpaperView.test.tsx
@@ -621,7 +621,10 @@ describe("WallpaperView", () => {
renderView({ available: false, count: 0, styles: [], items: [] });
expect(await screen.findByAltText("The Original")).toBeTruthy();
- expect(screen.getByText(/No wallpaper library installed/)).toBeTruthy();
+ expect(
+ screen.getByText(/500 more wallpapers are one download away/),
+ ).toBeTruthy();
+ expect(screen.getByRole("button", { name: /Download library/ })).toBeTruthy();
});
it("still offers the original when the catalog request fails", async () => {
diff --git a/jarvis/ui/web/frontend/src/views/WallpaperView.tsx b/jarvis/ui/web/frontend/src/views/WallpaperView.tsx
index e63b9fbefd..73d56869b4 100644
--- a/jarvis/ui/web/frontend/src/views/WallpaperView.tsx
+++ b/jarvis/ui/web/frontend/src/views/WallpaperView.tsx
@@ -3,6 +3,7 @@ import {
Check,
ChevronLeft,
ChevronRight,
+ Download,
Heart,
Image as ImageIcon,
Loader2,
@@ -30,6 +31,10 @@ import {
UPLOAD_WALLPAPER_STYLE,
} from "@/hooks/useWallpaperUploads";
import { useApplyWallpaper } from "@/hooks/useApplyWallpaper";
+import {
+ installRunning,
+ useWallpaperLibraryInstall,
+} from "@/hooks/useWallpaperLibrary";
import { useThemeValue, type Theme } from "@/hooks/useTheme";
import { useWallpaperStore } from "@/store/wallpaper";
import { cn } from "@/lib/utils";
@@ -90,6 +95,88 @@ function SegmentButton({
);
}
+/** Whole megabytes for the download banner — nobody needs decimals here. */
+function formatMb(bytes: number): string {
+ return `${Math.max(1, Math.round(bytes / (1024 * 1024)))} MB`;
+}
+
+/**
+ * The banner a machine without the generated library gets: what is missing,
+ * how big it is, and the one button that fixes it. While the server downloads
+ * and unpacks, the button gives way to a progress bar; when the install lands,
+ * the catalog refetch replaces this banner with five hundred tiles.
+ */
+function LibraryDownloadBanner() {
+ const { status, start } = useWallpaperLibraryInstall();
+ const state = status.data ?? undefined;
+ const running = installRunning(state);
+ const failed = state?.state === "error";
+ const percent =
+ running && state && state.totalBytes > 0
+ ? Math.min(99, Math.round((state.receivedBytes / state.totalBytes) * 100))
+ : 0;
+
+ return (
+ <div className="border-b border-border px-6 py-3">
+ <div className="flex flex-wrap items-center gap-x-4 gap-y-2">
+ <div className="min-w-0 flex-1">
+ <p className="text-xs">
+ <span className="font-medium text-foreground">
+ 500 more wallpapers are one download away.
+ </span>{" "}
+ <span className="text-muted-foreground">
+ The generated collection is content, not code — it is fetched once
+ from the project&apos;s releases instead of weighing down every
+ checkout.
+ </span>
+ </p>
+ {failed && (
+ <p role="alert" className="mt-1 text-xs text-destructive">
+ {state?.error ?? "The download failed."}
+ </p>
+ )}
+ </div>
+ {running ? (
+ <div className="flex w-56 items-center gap-2">
+ <div
+ role="progressbar"
+ aria-valuenow={percent}
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-label="Wallpaper library download"
+ className="h-1.5 flex-1 overflow-hidden rounded-full bg-secondary"
+ >
+ <div
+ className="h-full rounded-full bg-primary transition-[width] duration-300"
+ style={{ width: `${percent}%` }}
+ />
+ </div>
+ <span className="whitespace-nowrap text-[11px] tabular-nums text-muted-foreground">
+ {state?.state === "unpacking"
+ ? "Unpacking…"
+ : `${formatMb(state?.receivedBytes ?? 0)} / ${formatMb(state?.totalBytes ?? 0)}`}
+ </span>
+ </div>
+ ) : (
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => start.mutate()}
+ disabled={start.isPending}
+ >
+ {start.isPending ? (
+ <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <Download className="mr-1.5 h-3.5 w-3.5" />
+ )}
+ {failed ? "Try again" : "Download library (~190 MB)"}
+ </Button>
+ )}
+ </div>
+ </div>
+ );
+}
+
/** The label the heart carries in both places it appears. */
function favoriteLabel(item: WallpaperEntry, favorite: boolean): string {
return favorite
@@ -620,19 +707,7 @@ export function WallpaperView() {
</p>
)}
- {!data?.libraryAvailable && (
- <p className="border-b border-border px-6 py-2.5 text-xs text-muted-foreground">
- <span className="font-medium text-foreground">
- No wallpaper library installed.
- </span>{" "}
- The generated collection lives in{" "}
- <code className="rounded bg-secondary/60 px-1 py-0.5">
- data/jarvis-wallpaper-gallery
- </code>
- , which is not part of the repository. Until it is there, the original
- below is the whole choice.
- </p>
- )}
+ {!data?.libraryAvailable && <LibraryDownloadBanner />}
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-border px-6 py-3">
<div className="flex items-center gap-1 rounded-lg border border-border p-0.5">
diff --git a/jarvis/ui/web/wallpapers.py b/jarvis/ui/web/wallpapers.py
index acf23f9714..c7007fe467 100644
--- a/jarvis/ui/web/wallpapers.py
+++ b/jarvis/ui/web/wallpapers.py
@@ -33,9 +33,13 @@ import json
import os
import re
import secrets
+import shutil
import tempfile
import threading
import time
+import urllib.error
+import urllib.request
+import zipfile
from dataclasses import dataclass
from pathlib import Path
from typing import Any
@@ -94,6 +98,28 @@ _LIGHT_THEME_LUMA = 128
#: Immutable content: the files are generated once and never edited in place.
_CACHE_HEADERS = {"Cache-Control": "public, max-age=31536000, immutable"}
+#: Where the packaged library is downloaded from when the owner asks for it.
+#: A dedicated asset release with a stable tag, deliberately separate from the
+#: product releases so the URL never moves when a new version ships. The ENV
+#: override exists for mirrors and for tests.
+LIBRARY_ARCHIVE_URL = os.environ.get(
+ "JARVIS_WALLPAPER_LIBRARY_URL",
+ "https://github.com/PersonalJarvis/PersonalJarvis/releases/download/"
+ "wallpaper-library-v1/jarvis-wallpaper-gallery.zip",
+)
+
+#: What the download banner promises before the Content-Length is known.
+#: Kept as data, not prose, so the frontend formats it for the reader.
+LIBRARY_ARCHIVE_APPROX_BYTES = 199 * 1024 * 1024
+
+#: One streamed read of the archive download. Large enough that progress
+#: bookkeeping is noise, small enough that a poll sees movement.
+_DOWNLOAD_CHUNK = 1024 * 256
+
+#: Ceiling for the accepted archive. The real one is ~190 MB; a server that
+#: claims (or streams) several times that is answering with something else.
+MAX_ARCHIVE_BYTES = 1024 * 1024 * 1024
+
@dataclass(frozen=True)
class Wallpaper:
@@ -204,6 +230,15 @@ class WallpaperLibrary:
self._items = self._load()
return self._items
+ def reset(self) -> None:
+ """Forget the cached catalog so the next request re-reads the disk.
+
+ The one caller is the installer: the library appearing on disk is the
+ only event after which "loaded once, kept forever" stops being true.
+ """
+ with self._lock:
+ self._items = None
+
def get(self, item_id: str) -> Wallpaper | None:
if not _ID_PATTERN.match(item_id):
return None
@@ -552,10 +587,207 @@ def _derive_thumbnail(source_path: Path, target: Path, label: str) -> Path:
return source_path
+class LibraryInstallError(Exception):
+ """An install failure, with a sentence meant for the owner."""
+
+
+class WallpaperLibraryInstaller:
+ """Downloads the packaged library and unpacks it into the data directory.
+
+ The archive lives on a GitHub asset release rather than in the repository
+ (see the module docstring for why), so a fresh checkout gets the five
+ hundred wallpapers as a one-click download instead of a 190 MB clone tax.
+
+ One install at a time, tracked as plain state under a lock: the work runs
+ on a daemon thread and the frontend polls the status endpoint, which is
+ all a single-owner desktop app needs — a job queue here would be ceremony.
+ """
+
+ def __init__(
+ self,
+ library: WallpaperLibrary,
+ url: str | None = None,
+ ) -> None:
+ self._library = library
+ self._url = url or LIBRARY_ARCHIVE_URL
+ self._lock = threading.Lock()
+ self._thread: threading.Thread | None = None
+ self._state = "idle" # idle | downloading | unpacking | done | error
+ self._received = 0
+ self._total: int | None = None
+ self._error: str | None = None
+
+ def status(self) -> dict[str, Any]:
+ with self._lock:
+ return {
+ "installed": self._installed(),
+ "state": self._state,
+ "receivedBytes": self._received,
+ "totalBytes": self._total or LIBRARY_ARCHIVE_APPROX_BYTES,
+ "error": self._error,
+ }
+
+ def _installed(self) -> bool:
+ root = self._library.root
+ return (root / "manifests").is_dir() and (root / "images").is_dir()
+
+ def start(self) -> dict[str, Any]:
+ """Begin the install unless one is already running or already done."""
+ with self._lock:
+ if self._thread is not None and self._thread.is_alive():
+ pass # already running; the status below says so
+ elif self._installed():
+ self._state = "done"
+ else:
+ self._state = "downloading"
+ self._received = 0
+ self._error = None
+ self._thread = threading.Thread(
+ target=self._run, name="wallpaper-library-install", daemon=True
+ )
+ self._thread.start()
+ return self.status()
+
+ def _set(self, **fields: Any) -> None:
+ with self._lock:
+ for key, value in fields.items():
+ setattr(self, f"_{key}", value)
+
+ def _run(self) -> None:
+ try:
+ archive = self._download()
+ try:
+ self._set(state="unpacking")
+ self._unpack(archive)
+ finally:
+ try:
+ archive.unlink()
+ except OSError:
+ pass
+ self._library.reset()
+ self._set(state="done")
+ logger.info("Wallpaper library installed under {}", self._library.root)
+ except LibraryInstallError as exc:
+ self._set(state="error", error=str(exc))
+ logger.warning("Wallpaper library install failed: {}", exc)
+ except Exception as exc: # noqa: BLE001 — the thread must never die silently
+ self._set(state="error", error=f"Unexpected error: {exc}")
+ logger.exception("Wallpaper library install crashed")
+
+ def _download(self) -> Path:
+ """Stream the archive to a temporary file beside its final home.
+
+ Beside it on purpose: the unpack step renames files into place, and a
+ temp file on another volume would turn that into a copy.
+ """
+ workdir = self._library.root.parent
+ workdir.mkdir(parents=True, exist_ok=True)
+ fd, tmp_name = tempfile.mkstemp(
+ prefix=".wallpaper-library.", suffix=".zip", dir=str(workdir)
+ )
+ tmp_path = Path(tmp_name)
+ # S310: the URL is the module's fixed https constant (or the owner's
+ # own ENV override / a test's file fixture), never request input.
+ request = urllib.request.Request( # noqa: S310
+ self._url, headers={"User-Agent": "PersonalJarvis-wallpaper-installer"}
+ )
+ try:
+ with os.fdopen(fd, "wb") as sink:
+ # S310: the URL is the module's fixed https constant (or the
+ # owner's own ENV override / a test's file fixture), never
+ # request input.
+ with urllib.request.urlopen(request, timeout=60) as response: # noqa: S310
+ length = response.headers.get("Content-Length")
+ if length and length.isdigit():
+ self._set(total=int(length))
+ received = 0
+ while True:
+ chunk = response.read(_DOWNLOAD_CHUNK)
+ if not chunk:
+ break
+ received += len(chunk)
+ if received > MAX_ARCHIVE_BYTES:
+ raise LibraryInstallError(
+ "The download is far larger than the library archive."
+ )
+ sink.write(chunk)
+ self._set(received=received)
+ return tmp_path
+ except (urllib.error.URLError, OSError, TimeoutError) as exc:
+ try:
+ tmp_path.unlink()
+ except OSError:
+ pass
+ reason = getattr(exc, "reason", None) or exc
+ raise LibraryInstallError(
+ f"Could not download the wallpaper library: {reason}"
+ ) from exc
+
+ def _unpack(self, archive: Path) -> None:
+ """Extract into a staging directory, then move into the library root.
+
+ Staged so a crash mid-extract cannot leave a half library that would
+ answer ``available: true`` with a fraction of the catalog. Every member
+ path is validated before a byte is written — the archive is downloaded
+ content, and this is the boundary where it could otherwise name a path
+ outside the library.
+ """
+ staging = Path(
+ tempfile.mkdtemp(
+ prefix=".wallpaper-library.unpack.", dir=str(self._library.root.parent)
+ )
+ )
+ try:
+ try:
+ with zipfile.ZipFile(archive) as bundle:
+ for member in bundle.infolist():
+ name = member.filename
+ parts = Path(name).parts
+ if (
+ not parts
+ or parts[0] not in {"images", "manifests"}
+ or ".." in parts
+ or name.startswith(("/", "\\"))
+ or ":" in name
+ ):
+ raise LibraryInstallError(
+ "The archive contains files it should not — refusing it."
+ )
+ if member.is_dir():
+ continue
+ target = staging.joinpath(*parts)
+ target.parent.mkdir(parents=True, exist_ok=True)
+ with bundle.open(member) as source, target.open("wb") as sink:
+ shutil.copyfileobj(source, sink)
+ except zipfile.BadZipFile as exc:
+ raise LibraryInstallError(
+ "The downloaded file is not a readable archive."
+ ) from exc
+ if not (staging / "manifests").is_dir() or not (staging / "images").is_dir():
+ raise LibraryInstallError(
+ "The archive is missing the library's manifests or images."
+ )
+
+ root = self._library.root
+ if not root.exists():
+ os.replace(staging, root)
+ return
+ # The root already exists (thumbnails, an aborted earlier attempt):
+ # move the two content directories into it individually.
+ for sub in ("manifests", "images"):
+ target = root / sub
+ if target.exists():
+ shutil.rmtree(target, ignore_errors=True)
+ os.replace(staging / sub, target)
+ finally:
+ shutil.rmtree(staging, ignore_errors=True)
+
+
def register_wallpaper_routes(
app: FastAPI,
library: WallpaperLibrary | None = None,
uploads: WallpaperUploads | None = None,
+ installer: WallpaperLibraryInstaller | None = None,
) -> None:
"""Mount the wallpaper endpoints under ``/api``.
@@ -565,11 +797,23 @@ def register_wallpaper_routes(
"""
lib = library or WallpaperLibrary()
own = uploads or WallpaperUploads()
+ setup = installer or WallpaperLibraryInstaller(lib)
@app.get("/api/wallpapers")
async def list_wallpapers() -> dict[str, Any]:
return lib.catalog()
+ # The library installer: how a fresh machine gets the five hundred
+ # wallpapers this repository deliberately does not carry.
+
+ @app.get("/api/wallpapers/library")
+ async def library_status() -> dict[str, Any]:
+ return setup.status()
+
+ @app.post("/api/wallpapers/library/install")
+ async def library_install() -> dict[str, Any]:
+ return setup.start()
+
# The upload routes are declared before the ``{item_id}`` ones purely for
# reading order — they never collide, because every upload path carries the
# literal ``uploads`` segment at a depth the catalog routes do not use.
diff --git a/tests/unit/ui/test_wallpaper_routes.py b/tests/unit/ui/test_wallpaper_routes.py
index 655cbcef17..09d7e4e765 100644
--- a/tests/unit/ui/test_wallpaper_routes.py
+++ b/tests/unit/ui/test_wallpaper_routes.py
@@ -35,6 +35,7 @@ from jarvis.ui.web.wallpapers import (
THUMB_WIDTH,
UPLOAD_MAX_WIDTH,
WallpaperLibrary,
+ WallpaperLibraryInstaller,
WallpaperUploads,
register_wallpaper_routes,
)
@@ -420,3 +421,127 @@ def test_manifest_paths_pointing_outside_the_library_are_dropped(
)
assert WallpaperLibrary(root).items() == {}
+
+
+# ---------------------------------------------------------------------------
+# The library installer: how a fresh machine gets the five hundred wallpapers
+# the repository deliberately does not carry.
+# ---------------------------------------------------------------------------
+
+
+def _library_archive(tmp_path: Path, name: str = "library.zip") -> Path:
+ """A miniature packaged library, shaped like the released one."""
+ import zipfile
+
+ image = tmp_path / "src-image.webp"
+ _write_wallpaper(image, (30, 40, 50))
+ manifest = [
+ {
+ "id": "01-cinematic-photoreal-01",
+ "title": "Flooded Observatory",
+ "style": "Cinematic Photorealistic",
+ "theme": "dark",
+ "file": "images/01-cinematic-photoreal/01.webp",
+ }
+ ]
+ archive = tmp_path / name
+ with zipfile.ZipFile(archive, "w") as bundle:
+ bundle.writestr("manifests/01-cinematic-photoreal.json", json.dumps(manifest))
+ bundle.write(image, "images/01-cinematic-photoreal/01.webp")
+ return archive
+
+
+def _wait_for_install(client: TestClient, timeout: float = 10.0) -> dict:
+ """Poll the status endpoint until the daemon thread settles."""
+ import time
+
+ deadline = time.monotonic() + timeout
+ while time.monotonic() < deadline:
+ status = client.get("/api/wallpapers/library").json()
+ if status["state"] in {"done", "error"}:
+ return status
+ time.sleep(0.02)
+ pytest.fail(f"install never settled: {status}")
+
+
+def _install_client(tmp_path: Path, archive_name: str = "library.zip") -> TestClient:
+ """An app whose installer pulls from a local archive instead of GitHub."""
+ library = WallpaperLibrary(tmp_path / "data" / "jarvis-wallpaper-gallery")
+ installer = WallpaperLibraryInstaller(
+ library, url=(tmp_path / archive_name).as_uri()
+ )
+ app = FastAPI()
+ register_wallpaper_routes(
+ app, library, WallpaperUploads(tmp_path / "uploads"), installer
+ )
+ return TestClient(app)
+
+
+def test_installing_the_library_fills_the_catalog(tmp_path: Path) -> None:
+ _library_archive(tmp_path)
+ client = _install_client(tmp_path)
+ assert client.get("/api/wallpapers").json()["available"] is False
+
+ started = client.post("/api/wallpapers/library/install").json()
+ assert started["state"] in {"downloading", "unpacking", "done"}
+ assert _wait_for_install(client)["state"] == "done"
+
+ payload = client.get("/api/wallpapers").json()
+ assert payload["available"] is True
+ assert payload["items"][0]["id"] == "01-cinematic-photoreal-01"
+ # The downloaded archive and the staging directory are cleaned up.
+ leftovers = list((tmp_path / "data").glob(".wallpaper-library*"))
+ assert leftovers == []
+
+
+def test_an_already_installed_library_is_not_downloaded_again(
+ tmp_path: Path, library: WallpaperLibrary
+) -> None:
+ installer = WallpaperLibraryInstaller(library, url="https://127.0.0.1:1/nope.zip")
+ app = FastAPI()
+ register_wallpaper_routes(app, library, WallpaperUploads(tmp_path / "u"), installer)
+ client = TestClient(app)
+
+ assert client.get("/api/wallpapers/library").json()["installed"] is True
+ # Starting anyway is a no-op answered with "done", not a download attempt.
+ assert client.post("/api/wallpapers/library/install").json()["state"] == "done"
+
+
+def test_an_unreachable_archive_is_an_error_state_not_a_crash(tmp_path: Path) -> None:
+ client = _install_client(tmp_path, archive_name="missing.zip")
+
+ client.post("/api/wallpapers/library/install")
+ status = _wait_for_install(client)
+
+ assert status["state"] == "error"
+ assert status["error"]
+ assert client.get("/api/wallpapers").json()["available"] is False
+
+
+def test_an_archive_reaching_outside_the_library_is_refused(tmp_path: Path) -> None:
+ """Zip-slip: a member path must not be able to escape the staging area."""
+ import zipfile
+
+ archive = tmp_path / "library.zip"
+ with zipfile.ZipFile(archive, "w") as bundle:
+ bundle.writestr("manifests/01-style.json", "[]")
+ bundle.writestr("images/../../evil.txt", "gotcha")
+ client = _install_client(tmp_path)
+
+ client.post("/api/wallpapers/library/install")
+ status = _wait_for_install(client)
+
+ assert status["state"] == "error"
+ assert not (tmp_path / "evil.txt").exists()
+ assert not (tmp_path / "data" / "jarvis-wallpaper-gallery").exists()
+
+
+def test_an_archive_that_is_not_a_zip_is_refused(tmp_path: Path) -> None:
+ (tmp_path / "library.zip").write_bytes(b"this is an html error page")
+ client = _install_client(tmp_path)
+
+ client.post("/api/wallpapers/library/install")
+ status = _wait_for_install(client)
+
+ assert status["state"] == "error"
+ assert "archive" in status["error"]