feat(server): show the Unraid array's free space and check the archive volume before filing uploads
On Unraid the archive is a user share (FUSE shfs), which reports the share's primary storage, often the cache, while the mover sends the photos to the array: the admin panel showed the cache's free space (owner review 2, R2). - New option SpacePath (server.json) / CHRONOS_SPACE_PATH: the admin panel shows that folder's volume; empty, or a folder that cannot be measured, falls back to the archive's volume (one warning, at start, not per request). - VolumeSpace measures folders (DriveInfo; the path root on Windows) and reads the filesystem type and mount from /proc/self/mountinfo on Linux (longest mount point on segment boundaries, octal escapes, optional fields, the top of stacked mounts), since DriveFormat calls an shfs share only "fuse". It is an injectable service, so tests simulate a full volume; the /data checks use it. - ArchiveStatsDto keeps FreeBytes/CapacityBytes for the shown volume and gains optional trailing members: the write volume's figures (when a space path is in use and they differ), the filesystem type and UsesSpacePath. - Admin panel (dashboard and archive): a tooltip on the storage figures names the volume and its filesystem and, on an shfs share without a space path, says they are the primary storage and to map the array view to /space; a "Write volume" line shows the archive's own volume when it differs. - Completing an upload, a render upload or a render node's result checks the archive volume for its size plus the 64 MiB reserve before the staging copy and answers 507 insufficient_storage, the upload still receiving. - Diagnostics list the archive and space volumes with filesystem and mount. - Unraid template: optional read-only "Array view" /space (default /mnt/user0/Timelapse) and "Space path" CHRONOS_SPACE_PATH=/space; compose and the releases README describe the same as an option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5209579631
commit
d560b41b81
22 files changed
+641
-66
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// Archive (BRIEF §14.8): naming templates, proxy policy, scan/rebuild/verify/maintenance, statistics.
|
||||
import { t, plural, applyStrings } from "../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, bar, columns, toast, errorText, emptyState, markInvalid, clearInvalid, invalidText, escapeReverts } from "../ui.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, bar, storageTip, writeVolumeLine, columns, toast, errorText, emptyState, markInvalid, clearInvalid, invalidText, escapeReverts } from "../ui.js";
|
||||
|
||||
const PROXY_SIZES = [-1, 1280, 1920, 2560, 3840, 0];
|
||||
const ACTIONS = ["scan", "rebuild", "verify", "maintenance"];
|
||||
@@ -15,7 +15,9 @@ export async function render(root, { api, setMeta }) {
|
||||
return;
|
||||
}
|
||||
setMeta(settings.rootPath, { ltr: true });
|
||||
// The space volume's figures (the space path when the server has one), the write volume apart when it differs.
|
||||
const used = stats.capacityBytes > 0 ? (stats.capacityBytes - stats.freeBytes) / stats.capacityBytes : 0;
|
||||
const spaceTip = attr(storageTip(stats));
|
||||
const sizes = PROXY_SIZES.includes(settings.proxyLongEdge) ? PROXY_SIZES : [settings.proxyLongEdge, ...PROXY_SIZES];
|
||||
const proxyOptions = sizes.map((size) => `<option value="${size}" ${size === settings.proxyLongEdge ? "selected" : ""}>${escapeHtml(proxyLabel(size))}</option>`).join("");
|
||||
const statsTable = (rows, labelId) => rows.length === 0 ? "" : `<div class="table compact stats" role="table" aria-labelledby="${labelId}"><div role="rowgroup">${rows.map((r) =>
|
||||
@@ -28,8 +30,8 @@ export async function render(root, { api, setMeta }) {
|
||||
<span class="sub">${escapeHtml(`${plural("Admin.Dashboard.PhotoCount", stats.photos)} · ${plural("Admin.Dashboard.CameraCount", stats.cameras)}`)}</span></section>
|
||||
<section class="panel tile" aria-labelledby="tile-originals"><h2 class="label" id="tile-originals" data-i18n="Admin.Archive.Originals"></h2><span class="value">${escapeHtml(formatBytes(stats.bytes))}</span>
|
||||
<span class="sub num">${escapeHtml(stats.firstYear ? `${stats.firstYear}–${stats.lastYear}` : "—")}</span></section>
|
||||
<section class="panel tile" aria-labelledby="tile-storage"><h2 class="label" id="tile-storage" data-i18n="Admin.Dashboard.Storage"></h2><span class="value">${escapeHtml(formatBytes(stats.freeBytes))}<small data-i18n="Admin.Archive.FreeShort"></small></span>
|
||||
${bar(used)}<span class="sub">${escapeHtml(t("Admin.Dashboard.Of", formatBytes(stats.capacityBytes)))}</span></section>
|
||||
<section class="panel tile" aria-labelledby="tile-storage"><h2 class="label" id="tile-storage" data-i18n="Admin.Dashboard.Storage"></h2><span class="value" title="${spaceTip}">${escapeHtml(formatBytes(stats.freeBytes))}<small data-i18n="Admin.Archive.FreeShort"></small></span>
|
||||
${bar(used)}<span class="sub" title="${spaceTip}">${escapeHtml(t("Admin.Dashboard.Of", formatBytes(stats.capacityBytes)))}</span>${writeVolumeLine(stats)}</section>
|
||||
<section class="panel tile" aria-labelledby="tile-health"><h2 class="label" id="tile-health" data-i18n="Admin.Archive.Health"></h2><span class="value num">${formatNumber(stats.unverifiedSequences)}<small>${escapeHtml(plural("Admin.Archive.UnverifiedUnit", stats.unverifiedSequences))}</small></span>
|
||||
<span class="sub">${escapeHtml(plural("Admin.Dashboard.WithoutProxies", stats.sequencesWithoutProxies))}</span></section>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Dashboard (mockup Admin.html, BRIEF §14.8): storage, archive, jobs, render nodes, charts, activity, active jobs.
|
||||
import { t, plural, applyStrings, culture } from "../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, columns, toast, errorText, emptyState, redraw, fitColumns, PROXY_WARNING } from "../ui.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, storageTip, writeVolumeLine, columns, toast, errorText, emptyState, redraw, fitColumns, PROXY_WARNING } from "../ui.js";
|
||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders } from "../jobs.js";
|
||||
import { activityText } from "../audit.js";
|
||||
|
||||
@@ -30,8 +30,10 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
t(d.discovery ? "Admin.Dashboard.DiscoveryOn" : "Admin.Dashboard.DiscoveryOff")));
|
||||
actions.innerHTML = d.proxyWarning ? PROXY_WARNING : "";
|
||||
applyStrings(actions);
|
||||
// The space volume's figures (the space path when the server has one), the write volume apart when it differs.
|
||||
const a = d.archive;
|
||||
const used = a.capacityBytes > 0 ? (a.capacityBytes - a.freeBytes) / a.capacityBytes : 0;
|
||||
const spaceTip = attr(storageTip(a));
|
||||
const online = d.nodes.filter((n) => n.state !== "offline");
|
||||
const uploads = lastThirtyDays(d.uploads);
|
||||
const totalUploads = uploads.reduce((s, u) => s + u.value, 0);
|
||||
@@ -41,9 +43,10 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
<div class="tiles">
|
||||
<section class="panel tile" aria-labelledby="tile-storage">
|
||||
<h2 class="label" id="tile-storage" data-i18n="Admin.Dashboard.Storage"></h2>
|
||||
<span class="value">${escapeHtml(formatBytes(a.capacityBytes - a.freeBytes))}<small>${escapeHtml(t("Admin.Dashboard.Of", formatBytes(a.capacityBytes)))}</small></span>
|
||||
<span class="value" title="${spaceTip}">${escapeHtml(formatBytes(a.capacityBytes - a.freeBytes))}<small>${escapeHtml(t("Admin.Dashboard.Of", formatBytes(a.capacityBytes)))}</small></span>
|
||||
${bar(used)}
|
||||
<span class="sub">${escapeHtml(t("Admin.Dashboard.Free", formatBytes(a.freeBytes)))} · ${escapeHtml(t("Admin.Dashboard.Originals", formatBytes(a.bytes)))}</span>
|
||||
<span class="sub" title="${spaceTip}">${escapeHtml(t("Admin.Dashboard.Free", formatBytes(a.freeBytes)))} · ${escapeHtml(t("Admin.Dashboard.Originals", formatBytes(a.bytes)))}</span>
|
||||
${writeVolumeLine(a)}
|
||||
</section>
|
||||
<section class="panel tile" aria-labelledby="tile-archive">
|
||||
<h2 class="label" id="tile-archive" data-i18n="Admin.Dashboard.Archive"></h2>
|
||||
|
||||
@@ -56,6 +56,23 @@ export function bar(fraction, muted = false) {
|
||||
`<rect class="track" width="100" height="6" rx="3"/><rect class="fill" width="${width}" height="6" rx="3"/></svg>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tooltip of a storage tile's figures (archive stats): the volume they measure and its file system; on an Unraid share
|
||||
* without a space volume, that they are the share's primary storage.
|
||||
*/
|
||||
export function storageTip(stats) {
|
||||
const lines = [stats.usesSpacePath ? t("Admin.Dashboard.SpaceVolume.Tip") : t("Admin.Dashboard.Storage.Tip")];
|
||||
if (stats.fileSystem) lines.push(t("Admin.Dashboard.FileSystem", stats.fileSystem));
|
||||
if (stats.fileSystem === "fuse.shfs" && !stats.usesSpacePath) lines.push(t("Admin.Dashboard.UnraidShare.Tip"));
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
/** The write volume's free space as one more line of a storage tile, when the stats have it apart; "" otherwise. */
|
||||
export function writeVolumeLine(stats) {
|
||||
if (stats.writeFreeBytes == null) return "";
|
||||
return `<span class="sub" title="${attr(t("Admin.Dashboard.WriteVolume.Tip"))}">${escapeHtml(t("Admin.Dashboard.WriteVolume", formatBytes(stats.writeFreeBytes)))}</span>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Column chart named by label: values with labels under the bars and, when given, the value above each bar. Bars use
|
||||
* the accent colour, or the sun colour for upload activity. With edgeLabels the first and last labels align with the
|
||||
|
||||
Reference in new issue
Block a user