fix: address the rc.14 review
Settings no longer makes a folder an archive on its own: a typed or picked folder without archive.json is made one only after a confirmation naming it, and Settings > Import keeps this PC's archive folder and never creates one. A half-typed path or another PC's drive letter could otherwise get .chronos and sidecars written unasked. The server's structure check creates nothing in a root that lost its archive.json (an unmounted disk's empty mount point) and reports it unavailable; /health re-checks when its last check is over 10 s old, so a fix on the host shows without a dashboard read. The admin board reads the server newest first with Order off, counts Published over the server's total, and a Shift range runs along the lane picked in. Admin sizes keep number and unit together. A sent workspace render whose file left exports/ is no longer listed as missing. Desktop Board cards put their actions under the text while the player is open. Start-up range errors name the CHRONOS_* variable; the deploy guide documents the parallelism clamp and the log rule. Refs #29 #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
159a8e6939
commit
2c15ee0e09
25 files changed
+336
-53
No files matched your search
@@ -405,12 +405,14 @@ public sealed class AppSettings
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Import: <paramref name="imported"/> with this PC's own values taken from these settings: the session, the
|
||||
/// window and its rail, the sequence edited last, the first-run flag, and the workspace (its folder, the projects opened
|
||||
/// last and when). Changes and returns <paramref name="imported"/>.
|
||||
/// window and its rail, the sequence edited last, the first-run flag, the archive folder (another PC's drive letter can
|
||||
/// name one of this PC's own folders), and the workspace (its folder, the projects opened last and when). Changes and
|
||||
/// returns <paramref name="imported"/>.
|
||||
/// </summary>
|
||||
public AppSettings KeepLocalIn(AppSettings imported)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(imported);
|
||||
imported.LastArchivePath = LastArchivePath;
|
||||
imported.ProtectedToken = ProtectedToken;
|
||||
imported.ServerUrl = ServerUrl;
|
||||
imported.Window = Window;
|
||||
|
||||
@@ -108,7 +108,7 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
_s.LastArchivePath = v.Length == 0 ? null : Path.GetFullPath(v);
|
||||
Save();
|
||||
UpdateArchiveFree();
|
||||
_retarget = RetargetArchiveAsync();
|
||||
_retarget = RetargetArchiveAsync(offerCreate: true);
|
||||
}, () => Loc.L("Tooltips.Settings.ArchiveRoot"));
|
||||
FolderTemplate = new EditableField(_s.FolderTemplate, v => NamingPreview.Validate(v, isFolder: true), v =>
|
||||
{
|
||||
@@ -1166,11 +1166,13 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
|
||||
/// <summary>
|
||||
/// The archive folder changed: an archive already there is registered as at start (relinked when it moved) and given
|
||||
/// its rescan, and the rows show its settings; any other folder leaves them with this PC's defaults for new archives.
|
||||
/// Later edits never reach the archive shown before. Returns the archive registered at that folder (null for none),
|
||||
/// even when another folder has been chosen since: edits made for this one go there.
|
||||
/// its rescan, and the rows show its settings. A folder that is no archive yet becomes one in place, with the archive's
|
||||
/// whole layout (as Welcome's Create), only when <paramref name="offerCreate"/> and the user confirms it for that folder
|
||||
/// by name; otherwise the folder is only remembered and the rows keep this PC's defaults for new archives. Later edits
|
||||
/// never reach the archive shown before. Returns the archive registered at that folder (null for none), even when
|
||||
/// another folder has been chosen since: edits made for this one go there.
|
||||
/// </summary>
|
||||
private async Task<Archive?> RetargetArchiveAsync()
|
||||
private async Task<Archive?> RetargetArchiveAsync(bool offerCreate)
|
||||
{
|
||||
_archive = null;
|
||||
var root = _s.LastArchivePath;
|
||||
@@ -1180,8 +1182,8 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
{
|
||||
var opened = await Task.Run(async () => File.Exists(new ArchivePaths(root).ManifestPath) ? await archives.OpenAsync(root) : null);
|
||||
if (opened is not null) await Shell.Services.QueueScanAsync(opened, full: false);
|
||||
// A folder that is no archive yet becomes one in place, with the archive's whole layout (as Welcome's Create).
|
||||
else await Shell.Services.ArchiveSetup.CreateAsync(root);
|
||||
// Never on its own: a folder the user typed half of, or one of their own folders, would become an archive and be scanned.
|
||||
else if (offerCreate && ConfirmCreateArchive(root)) await Shell.Services.ArchiveSetup.CreateAsync(root);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or NewerFormatException
|
||||
or DatabaseException or ArgumentException or InvalidOperationException)
|
||||
@@ -1193,6 +1195,21 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
return await LoadArchiveAsync(root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The archive folder typed or picked holds no archive: the user confirms making it one, the folder named, before any
|
||||
/// folder or file is written there. Declined, the folder is only remembered.
|
||||
/// </summary>
|
||||
private bool ConfirmCreateArchive(string root) => Shell.Services.Dialogs.Confirm(new ConfirmRequest
|
||||
{
|
||||
Heading = Loc.L("Settings.Archive.CreateTitle"),
|
||||
Message = Loc.L("Settings.Archive.CreateMessage"),
|
||||
Detail = root,
|
||||
SafeText = Loc.L("Settings.Archive.CreateSkip"),
|
||||
SafeToolTip = Loc.L("Tooltips.Settings.SkipCreateArchive"),
|
||||
ActionText = Loc.L("Settings.Archive.CreateAction"),
|
||||
ActionToolTip = Loc.L("Tooltips.Settings.CreateArchiveHere"),
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Archive › Reset section with an archive open writes the defaults into that archive's archive.json, which the server
|
||||
/// and the other PCs share: the user confirms it for that archive by name first.
|
||||
@@ -1756,11 +1773,11 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
return;
|
||||
}
|
||||
// Everything but the session, the window and its rail, the sequence edited last (another PC's ids mean nothing here),
|
||||
// the first-run flag and the workspace, which is this PC's (its folder, the projects opened last and when).
|
||||
// the first-run flag, the archive folder and the workspace, which are this PC's (another PC's drives mean nothing here).
|
||||
ApplyAll(_s.KeepLocalIn(imported));
|
||||
// Settings of a PC never rewrite the shared archive.json: the imported templates and sizes are the defaults of new
|
||||
// archives, and the rows show the own settings of the archive at the (possibly imported) archive folder.
|
||||
_retarget = RetargetArchiveAsync();
|
||||
// archives, and the rows show the own settings of this PC's archive. An import never makes a folder an archive.
|
||||
_retarget = RetargetArchiveAsync(offerCreate: false);
|
||||
Shell.Notify(Loc.L("Settings.Import.Done"));
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,31 @@
|
||||
<Setter Property="ContextMenu" Value="{StaticResource Menu.Video}" />
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick" />
|
||||
</Style>
|
||||
<!--
|
||||
A Board card's text and its actions: beside each other, and the actions on a row of their own under the text while the
|
||||
player pane narrows the lanes (rc.14 review: at the window's smallest width the text kept about 80 px).
|
||||
-->
|
||||
<Style x:Key="Panel.BoardText" TargetType="StackPanel">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding DataContext.IsPlayerOpen, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="True">
|
||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="Panel.BoardActions" TargetType="StackPanel">
|
||||
<Setter Property="Orientation" Value="Horizontal" />
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Margin" Value="8,0,0,0" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding DataContext.IsPlayerOpen, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="True">
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Grid.Row" Value="1" />
|
||||
<Setter Property="Margin" Value="0,4,0,0" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<!-- A Board card: title, project and version, preset · codec · duration · size, kind · date, state chips, and its actions. -->
|
||||
<DataTemplate x:Key="Template.BoardCard" DataType="{x:Type vid:VideoRowViewModel}">
|
||||
<Grid ToolTip="{Binding ToolTip}">
|
||||
@@ -116,7 +141,11 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Style="{StaticResource Panel.BoardText}">
|
||||
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
|
||||
<TextBlock Style="{StaticResource Text.Secondary}" Text="{Binding ProjectText}" TextTrimming="CharacterEllipsis" Margin="0,2,0,0"
|
||||
Visibility="{Binding HasProject, Converter={StaticResource BoolToVisibility}}" />
|
||||
@@ -125,7 +154,7 @@
|
||||
<ItemsControl Margin="0,6,0,0" ItemsSource="{Binding States}" ItemTemplate="{StaticResource Template.Status}" ItemsPanel="{StaticResource Panel.Row}"
|
||||
Focusable="False" ClipToBounds="True" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Top" Margin="8,0,0,0">
|
||||
<StackPanel Style="{StaticResource Panel.BoardActions}">
|
||||
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Play}"
|
||||
Command="{Binding DataContext.PlayCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}"
|
||||
ToolTip="{Binding PlayToolTip}" AutomationProperties.Name="{l:Loc Videos.Play}" />
|
||||
|
||||
@@ -439,7 +439,10 @@ public static class VideoSources
|
||||
foreach (var render in folder.ReadRenders().Entries)
|
||||
{
|
||||
var path = folder.ExportFile(render.File);
|
||||
entries.Add(FromWorkspace(render, project, path, File.Exists(path) || Directory.Exists(path)));
|
||||
var exists = File.Exists(path) || Directory.Exists(path);
|
||||
// A sent render whose file left exports/ is safe at its home, whose entry stands for it: never "missing".
|
||||
if (render.IsSent && !exists) continue;
|
||||
entries.Add(FromWorkspace(render, project, path, exists));
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
|
||||
@@ -170,7 +170,8 @@ export class Selection {
|
||||
* stop (the current item), arrows move along the reading direction and between rows, Home and End, Space selects
|
||||
* (Shift+Space: the range from the last one picked), Enter opens, Ctrl+A selects everything shown, Esc clears the
|
||||
* selection. A click on an item's check box selects (with Shift, a range), Ctrl+click too; a plain click opens.
|
||||
* The caller redraws through onChange after the selection changed.
|
||||
* The caller redraws through onChange after the selection changed. order(el) gives the keys a range runs along, in the
|
||||
* order shown; el is the item picked, so a page with several groups (the videos board's lanes) can answer with its group.
|
||||
*/
|
||||
export function selectableGrid(host, { selection, order, open, onChange }) {
|
||||
let current = null;
|
||||
@@ -182,8 +183,9 @@ export function selectableGrid(host, { selection, order, open, onChange }) {
|
||||
current = el.dataset.key;
|
||||
el.focus();
|
||||
};
|
||||
const pick = (key, shift) => {
|
||||
if (shift) selection.range(key, order());
|
||||
const pick = (el, shift) => {
|
||||
const key = el.dataset.key;
|
||||
if (shift) selection.range(key, order(el));
|
||||
else selection.toggle(key);
|
||||
onChange();
|
||||
};
|
||||
@@ -201,7 +203,7 @@ export function selectableGrid(host, { selection, order, open, onChange }) {
|
||||
if (e.target.closest("[data-check]") || e.ctrlKey || e.metaKey || e.shiftKey) {
|
||||
// A check box keeps its own click (a cancelled one would put its old state back after onChange drew the new one).
|
||||
if (!e.target.matches("input[data-check]")) e.preventDefault();
|
||||
pick(el.dataset.key, e.shiftKey);
|
||||
pick(el, e.shiftKey);
|
||||
return;
|
||||
}
|
||||
if (e.target.closest("a, button")) return;
|
||||
@@ -223,7 +225,7 @@ export function selectableGrid(host, { selection, order, open, onChange }) {
|
||||
case "End": next = list[list.length - 1]; break;
|
||||
case " ":
|
||||
e.preventDefault();
|
||||
pick(el.dataset.key, e.shiftKey);
|
||||
pick(el, e.shiftKey);
|
||||
return;
|
||||
case "Enter":
|
||||
e.preventDefault();
|
||||
|
||||
@@ -103,6 +103,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
for (const f of ["kind", "codec", "year", "sort"]) root.querySelector(`#${f}`).addEventListener("change", (e) => setFilter(f, e.target.value));
|
||||
root.querySelector("#clear").addEventListener("click", clearFilters);
|
||||
root.querySelectorAll("[data-view]").forEach((b) => b.addEventListener("click", () => {
|
||||
const sortBefore = sortShown();
|
||||
view = b.dataset.view;
|
||||
root.querySelectorAll("[data-view]").forEach((x) => x.setAttribute("aria-pressed", String(x === b)));
|
||||
try {
|
||||
@@ -110,13 +111,22 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
} catch {
|
||||
// Only this page keeps the view then.
|
||||
}
|
||||
draw();
|
||||
drawSort();
|
||||
// The board reads the server newest first: the list read again in the order the view shows, as a new filter is
|
||||
// (the selection could hold videos the new page does not show).
|
||||
if (sortShown() !== sortBefore) {
|
||||
selection.clear();
|
||||
load();
|
||||
} else draw();
|
||||
}));
|
||||
root.querySelector("#more").addEventListener("click", () => load(true));
|
||||
|
||||
const grid = selectableGrid(itemsHost, {
|
||||
selection,
|
||||
order: () => rows.map((v) => v.id),
|
||||
// On the board a range runs along the lane picked in, as its cards are shown (a sent render is in both lanes).
|
||||
order: (el) => view === "board" && el?.closest(".board-lane")
|
||||
? [...el.closest(".board-lane").querySelectorAll('[role="option"]')].map((e) => e.dataset.key)
|
||||
: rows.map((v) => v.id),
|
||||
open: (key) => play(rows.find((v) => v.id === key)),
|
||||
onChange: syncSelection,
|
||||
});
|
||||
@@ -148,10 +158,23 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
return FILTERS.some((f) => f !== "sort" && filters[f]);
|
||||
}
|
||||
|
||||
/** The order read from the server: the board's lanes are newest first over every video, whatever Order says. */
|
||||
function sortShown() {
|
||||
return view === "board" ? "newest" : filters.sort;
|
||||
}
|
||||
|
||||
/** On the board, Order is off and says why; the choice comes back with the cards or the list. */
|
||||
function drawSort() {
|
||||
const sort = root.querySelector("#sort");
|
||||
sort.disabled = view === "board";
|
||||
sort.dataset.i18nTitle = view === "board" ? "Admin.Videos.Sort.Board.Tip" : "Admin.Videos.Sort.Tip";
|
||||
sort.title = t(sort.dataset.i18nTitle);
|
||||
}
|
||||
|
||||
function listQuery(limit, after) {
|
||||
const p = new URLSearchParams({ limit: String(limit) });
|
||||
for (const f of ["q", "kind", "codec", "year", "sequence"]) if (filters[f]) p.set(f, filters[f]);
|
||||
if (filters.sort !== "newest") p.set("sort", filters.sort);
|
||||
if (sortShown() !== "newest") p.set("sort", sortShown());
|
||||
if (after) p.set("cursor", after);
|
||||
return `/api/v1/videos?${p}`;
|
||||
}
|
||||
@@ -310,18 +333,19 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The two lanes, newest first whatever the order chosen, each with its count: Published holds every video shown, Workspace
|
||||
* those a PC's workspace sent here, again as cards of their own marked Sent.
|
||||
* The two lanes, newest first (the board reads the server in that order, sortShown), each with its count: Published holds
|
||||
* every video, counted over the server (the server's total), Workspace those a PC's workspace sent here, again as cards
|
||||
* of their own marked Sent, counted among the videos read so far ("12+" while more can be read).
|
||||
*/
|
||||
function boardHtml() {
|
||||
const newest = [...rows].sort((a, b) => (Date.parse(b.created) - Date.parse(a.created)) || String(a.id).localeCompare(String(b.id)));
|
||||
const sent = newest.filter((v) => boardLane(v, serverName) === "workspace");
|
||||
const lane = (key, items, workspace) => `<section class="board-lane" aria-label="${attr(t(`Admin.Videos.Lane.${key}`))}">
|
||||
const sent = rows.filter((v) => boardLane(v, serverName) === "workspace");
|
||||
const lane = (key, items, workspace, count) => `<section class="board-lane" aria-label="${attr(t(`Admin.Videos.Lane.${key}`))}">
|
||||
<h2 class="board-head" title="${attr(t(`Admin.Videos.Lane.${key}.Tip`))}"><span>${escapeHtml(t(`Admin.Videos.Lane.${key}`))}</span>
|
||||
<span class="pill num">${escapeHtml(formatNumber(items.length))}</span></h2>
|
||||
<span class="pill num">${escapeHtml(count)}</span></h2>
|
||||
<div class="board-cards">${items.length > 0 ? items.map((v) => itemHtml(v, workspace)).join("")
|
||||
: `<p class="empty-lane">${escapeHtml(t("Admin.Videos.Empty"))}</p>`}</div></section>`;
|
||||
return lane("Published", newest, false) + lane("Workspace", sent, true);
|
||||
return lane("Published", rows, false, formatNumber(total ?? rows.length))
|
||||
+ lane("Workspace", sent, true, `${formatNumber(sent.length)}${cursor ? "+" : ""}`);
|
||||
}
|
||||
|
||||
function itemHtml(v, workspace = false) {
|
||||
@@ -585,6 +609,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
else if (e.type === "reconnected") refreshSoon(0);
|
||||
});
|
||||
drawFilters();
|
||||
drawSort();
|
||||
await load();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export function formatNumber(n) {
|
||||
return new Intl.NumberFormat(culture()).format(n ?? 0);
|
||||
}
|
||||
|
||||
/** 9.4 TB, 610 GB … (decimal units, like disk vendors and the desktop client). */
|
||||
/** 9.4 TB, 610 GB … (decimal units, like disk vendors and the desktop client), number and unit held together by a no-break space. */
|
||||
export function formatBytes(bytes) {
|
||||
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
||||
let value = Number(bytes ?? 0);
|
||||
@@ -22,7 +22,7 @@ export function formatBytes(bytes) {
|
||||
unit++;
|
||||
}
|
||||
const digits = value >= 100 || unit === 0 ? 0 : 1;
|
||||
return `${new Intl.NumberFormat(culture(), { maximumFractionDigits: digits }).format(value)} ${units[unit]}`;
|
||||
return `${new Intl.NumberFormat(culture(), { maximumFractionDigits: digits }).format(value)} ${units[unit]}`;
|
||||
}
|
||||
|
||||
export function formatTime(iso) {
|
||||
|
||||
@@ -80,8 +80,15 @@ public static class SystemEndpoints
|
||||
{
|
||||
var checks = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
// "incomplete": a folder of the archive's layout could not be created (the dashboard says which and why).
|
||||
["archive"] = !Directory.Exists(options.ArchivePath) ? "missing" : archive.Structure is { IsComplete: false } ? "incomplete" : "ok",
|
||||
// "missing": the root or its archive.json is not there (an unmounted disk); "incomplete": a folder of the archive's
|
||||
// layout could not be created (the dashboard says which and why). Checked again once the last check is older than
|
||||
// HealthRecheck, so a fix on the host shows here without the dashboard.
|
||||
["archive"] = archive.CheckStructure(archive.HealthRecheck) switch
|
||||
{
|
||||
{ Problem: Core.Archiving.ArchiveStructureProblem.Unavailable } => "missing",
|
||||
{ IsComplete: false } => "incomplete",
|
||||
_ => "ok",
|
||||
},
|
||||
["data"] = Directory.Exists(options.DataPath) ? "ok" : "missing",
|
||||
};
|
||||
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(context.RequestAborted);
|
||||
|
||||
@@ -392,7 +392,7 @@ public sealed class ServerOptions
|
||||
throw new InvalidOperationException("CHRONOS_TLS_MODE=pem requires CHRONOS_TLS_CERT and CHRONOS_TLS_KEY.");
|
||||
// Port 0 asks the OS for a free port (used by the in-process test host).
|
||||
if (HttpPort is < 0 or > 65535 || HttpsPort is < 0 or > 65535)
|
||||
throw new InvalidOperationException("Ports must be between 0 and 65535.");
|
||||
throw new InvalidOperationException("CHRONOS_HTTP_PORT and CHRONOS_HTTPS_PORT must be between 0 and 65535.");
|
||||
if (PublicHttpPort is < 1 or > 65535 || PublicHttpsPort is < 1 or > 65535)
|
||||
throw new InvalidOperationException("CHRONOS_PUBLIC_HTTP_PORT and CHRONOS_PUBLIC_HTTPS_PORT must be between 1 and 65535.");
|
||||
try
|
||||
@@ -410,7 +410,7 @@ public sealed class ServerOptions
|
||||
if (MaxUploadBytes < 1 || TokenLifetimeDays < 1 || JobHistoryDays < 1 || UploadRetentionHours < 1)
|
||||
throw new InvalidOperationException("Upload size, token lifetime, job history and upload retention must be positive.");
|
||||
if (ServerLogging.Problem(LogRetentionDays, LogMaxFileMb, LogMaxTotalMb, AuditRetentionDays, DiagnosticsLogMb) is { } log)
|
||||
throw new InvalidOperationException($"{log} is out of range: {ServerLogging.Ranges}.");
|
||||
throw new InvalidOperationException($"{VariableOf(log) ?? log} is out of range: {ServerLogging.Ranges}.");
|
||||
if (!ServerLogging.IsLevel(LogLevel) || !ServerLogging.IsLevel(ConsoleLogLevel) || !Enum.IsDefined(LogRotation))
|
||||
throw new InvalidOperationException("CHRONOS_LOG_LEVEL, CHRONOS_LOG_CONSOLE_LEVEL or CHRONOS_LOG_ROTATION has an unknown value.");
|
||||
}
|
||||
|
||||
@@ -54,15 +54,31 @@ public sealed class ServerArchive(Archive archive)
|
||||
public ArchiveStructureReport? Structure => _structure;
|
||||
|
||||
private volatile ArchiveStructureReport? _structure;
|
||||
private long _checkedAt = long.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// How old the last <see cref="CheckStructure"/> may be when <c>/health</c> answers before it checks again: a fix made
|
||||
/// on the host shows there without anyone opening the dashboard. Tests shorten it.
|
||||
/// </summary>
|
||||
public TimeSpan HealthRecheck { get; set; } = TimeSpan.FromSeconds(10);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the folders of the archive's layout that are missing (BRIEF §7) and remembers what it found
|
||||
/// (<see cref="Structure"/>): at start, and each time the dashboard is read, so a share that comes back heals.
|
||||
/// (<see cref="Structure"/>): at start, each time the dashboard is read and when <c>/health</c> finds the last check
|
||||
/// older than <paramref name="maxAge"/>, so a share that comes back heals. A root that holds no <c>archive.json</c> (an
|
||||
/// unmounted disk leaves an empty mount point) is reported unavailable and nothing is created there.
|
||||
/// </summary>
|
||||
public ArchiveStructureReport CheckStructure()
|
||||
/// <param name="maxAge">The last check is returned as it is while younger than this; null always checks.</param>
|
||||
public ArchiveStructureReport CheckStructure(TimeSpan? maxAge = null)
|
||||
{
|
||||
var report = ArchiveStructure.Ensure(new ArchivePaths(Root));
|
||||
if (maxAge is { } age && _structure is { } recent && Environment.TickCount64 - Interlocked.Read(ref _checkedAt) < (long)age.TotalMilliseconds)
|
||||
return recent;
|
||||
var paths = new ArchivePaths(Root);
|
||||
var report = File.Exists(paths.ManifestPath)
|
||||
? ArchiveStructure.Ensure(paths)
|
||||
: new ArchiveStructureReport(paths.Root, [], ArchiveStructureProblem.Unavailable, paths.Root, null);
|
||||
_structure = report;
|
||||
Interlocked.Exchange(ref _checkedAt, Environment.TickCount64);
|
||||
return report;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user