/** Absolute on POSIX (`/…`), Windows (`C:\…`, `C:/…`) or a UNC share (`\\…`). */ function isAbsolute(path: string): boolean { return path.startsWith("/") || path.startsWith("\\") || /^[A-Za-z]:[\\/]/.test(path); } /** * The on-disk path of a row in the `downloads` store. * * `downloads.file_path` is stored relative to the storage root while a download * is queued, but the worker rewrites it to the absolute path it actually wrote * once the transfer completes — so a *completed* row is already rooted. Joining * it onto the storage root a second time produced * `/data/user/0/app//data/user/0/app/videos/x.mp4`; the asset protocol could not * open that, so offline video failed with `MEDIA_ERR_SRC_NOT_SUPPORTED` while * audio, which resolves the same column through Rust, played fine. * * TRACES: UR-071 | DR-133 | UT-124 */ export function downloadedFilePath(storageRoot: string, filePath: string): string { return isAbsolute(filePath) ? filePath : `${storageRoot}/${filePath}`; }