import { describe, it, expect } from "vitest"; import { downloadedFilePath } from "./localSource"; describe("downloadedFilePath", () => { // The download worker rewrites `downloads.file_path` to the absolute path it // actually wrote once the transfer completes, so a completed row is already // rooted. Joining it onto the storage root again produced // `/data/user/0/app//data/user/0/app/videos/x.mp4`, which the asset protocol // cannot open — offline video died with MEDIA_ERR_SRC_NOT_SUPPORTED while // audio, which resolves the same column through Rust, played fine. it("leaves a completed download's absolute path alone", () => { const root = "/data/user/0/com.dtourolle.jellytau"; const stored = `${root}/videos/Taming of the Shrew.mp4`; expect(downloadedFilePath(root, stored)).toBe(stored); }); it("roots a path that is still relative to the storage directory", () => { // Rows only hold a relative path before the worker completes them, but a // half-migrated database can still carry one. expect(downloadedFilePath("/var/data/jellytau", "videos/film.mp4")).toBe( "/var/data/jellytau/videos/film.mp4", ); }); it("leaves an absolute Windows path alone", () => { const stored = "C:\\Users\\u\\AppData\\jellytau\\videos\\film.mp4"; expect(downloadedFilePath("C:\\Users\\u\\AppData\\jellytau", stored)).toBe(stored); }); });