Initial commit: playlink music library hardlink deduplicator
Go backend (chi, SQLite) with an embedded React/TypeScript UI that finds songs present in both a host and a slave music library and replaces the slave copy with a hardlink to the host copy. - Path-first matching with format/title/album-folder fallbacks - Auto-linking of byte-identical files, re-verified with cmp before linking - Manual review with ffprobe quality comparison, downgrade guard and promote-to-host override - Build mode to populate an empty slave library from the host - Dry run by default, atomic stage+rename replacement, quarantine with retention, undo, path confinement and authenticated UI - Dockerfile and compose file for Unraid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ac47e61b08
42 files changed
+8892
No files matched your search
@@ -0,0 +1,116 @@
|
||||
import { useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { AlertTriangle, ArrowRight, Library, Plus } from "lucide-react";
|
||||
import { api, type Pair } from "../api";
|
||||
import { Badge, Button, Card, Empty, Spinner, formatAgo, formatBytes, statusTone } from "../ui";
|
||||
import { PairForm } from "./PairForm";
|
||||
import { JobBar, ScanButton } from "./PairPage";
|
||||
|
||||
export function Dashboard() {
|
||||
const [creating, setCreating] = useState(false);
|
||||
const pairs = useQuery({
|
||||
queryKey: ["pairs"],
|
||||
queryFn: () => api.get<Pair[]>("/pairs"),
|
||||
refetchInterval: (q) => (q.state.data?.some((p) => p.job?.state === "running") ? 1000 : 15000),
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-end justify-between gap-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold tracking-tight">Libraries</h1>
|
||||
<p className="text-sm text-muted">Each pair links matching songs from a slave library to the host library's copy.</p>
|
||||
</div>
|
||||
<Button variant="primary" onClick={() => setCreating(true)}>
|
||||
<Plus className="size-4" /> New pair
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{pairs.isLoading && <Spinner />}
|
||||
{pairs.data?.length === 0 && (
|
||||
<Card>
|
||||
<Empty icon={<Library className="size-10" />} title="No library pairs yet">
|
||||
Create a pair with a <b>host</b> library (e.g. Albums) and a <b>slave</b> library (e.g. your curated Singles). playlink finds songs in
|
||||
both and replaces the slave copy with a hardlink to the host copy, so each song is stored only once.
|
||||
<div className="mt-4">
|
||||
<Button variant="primary" onClick={() => setCreating(true)}>
|
||||
<Plus className="size-4" /> Create your first pair
|
||||
</Button>
|
||||
</div>
|
||||
</Empty>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
{pairs.data?.map((p) => <PairCard key={p.id} pair={p} />)}
|
||||
</div>
|
||||
<PairForm open={creating} onClose={() => setCreating(false)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PairCard({ pair }: { pair: Pair }) {
|
||||
const c = pair.summary.counts;
|
||||
const stats: [string, number][] = [
|
||||
["linked", c.linked ?? 0],
|
||||
["identical", c.identical ?? 0],
|
||||
["review", pair.summary.review],
|
||||
["unmatched", c.unmatched ?? 0],
|
||||
];
|
||||
return (
|
||||
<Card className="flex flex-col p-5">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<a href={`#/pair/${pair.id}`} className="text-lg font-semibold hover:text-accent">
|
||||
{pair.name}
|
||||
</a>
|
||||
<div className="mt-1 space-y-0.5 text-xs">
|
||||
<div className="truncate">
|
||||
<span className="text-muted">host</span> <code className="mono">{pair.host_root}</code>
|
||||
</div>
|
||||
<div className="truncate">
|
||||
<span className="text-muted">slave</span> <code className="mono">{pair.slave_root}</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ScanButton pair={pair} />
|
||||
</div>
|
||||
|
||||
<div className="mt-4 grid grid-cols-4 gap-2">
|
||||
{stats.map(([k, v]) => (
|
||||
<a
|
||||
key={k}
|
||||
href={`#/pair/${pair.id}/review?status=${k}`}
|
||||
className="rounded-lg border border-line bg-panel-2 px-3 py-2 hover:border-accent/50"
|
||||
>
|
||||
<div className="text-xl font-semibold tabular-nums">{v}</div>
|
||||
<Badge tone={k === "review" ? "amber" : statusTone[k]}>{k}</Badge>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-4 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted">
|
||||
<span>Reclaimable: <b className="text-sky-300">{formatBytes(pair.summary.reclaimable_bytes)}</b></span>
|
||||
<span>Deduplicated: <b className="text-emerald-300">{formatBytes(pair.summary.linked_bytes)}</b></span>
|
||||
<span>Last scan: {formatAgo(pair.last_scan_at)}</span>
|
||||
{pair.auto_link_identical && <Badge tone="blue">auto-link</Badge>}
|
||||
{pair.scan_interval_minutes > 0 && <Badge>every {pair.scan_interval_minutes}m</Badge>}
|
||||
</div>
|
||||
|
||||
{pair.job?.state === "running" && <JobBar job={pair.job} className="mt-4" />}
|
||||
{pair.last_scan_error && (
|
||||
<div className="mt-3 flex gap-2 text-xs text-red-300">
|
||||
<AlertTriangle className="size-3.5 shrink-0" /> {pair.last_scan_error}
|
||||
</div>
|
||||
)}
|
||||
{pair.last_scan_warnings.length > 0 && (
|
||||
<div className="mt-3 flex gap-2 text-xs text-amber-300">
|
||||
<AlertTriangle className="size-3.5 shrink-0" /> {pair.last_scan_warnings.length} layout warning{pair.last_scan_warnings.length > 1 && "s"}
|
||||
</div>
|
||||
)}
|
||||
<a href={`#/pair/${pair.id}`} className="mt-4 flex items-center gap-1 self-end text-sm text-accent hover:underline">
|
||||
Open <ArrowRight className="size-3.5" />
|
||||
</a>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user