feat: download lifecycle — stalled and failed downloads are given up and searched again; imported ones seed, then go (M502 #5523)
release / govulncheck (push) Successful in 17s
release / web (push) Failing after 17s
release / go (push) Successful in 1m11s
release / integration (push) Successful in 4m50s
release / android (push) Successful in 4m54s
release / Build signed APK (releases and dev) (push) Successful in 5m9s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 17s
release / web (push) Failing after 17s
release / go (push) Successful in 1m11s
release / integration (push) Successful in 4m50s
release / android (push) Successful in 4m54s
release / Build signed APK (releases and dev) (push) Successful in 5m9s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
Ported from Fabled Librarian's System 104. A new lifecycle poller, every ten minutes: - a download the client fails is given up at once; - one nobody shares, or still fetching its file list, past the stall setting (6 h) is asked for again three times, then given up; - giving up removes the download with its files, holds the release back for a week (release_blocks.expires_at), ends the grab and searches the album again, with no limit per album; - a running download the client stops listing for half an hour ends and is searched again, not held back; an empty list is not taken as gone; - an imported download seeds to ratio 2.0 or 14 days, then is removed; - a download the client would not remove is asked again every pass. Every condition and act is one open row per (client, download, condition) in download_interventions. Activity shows what is wrong with a download and how often it was retried, why one ended, its seeding, and a banner for a client that does not answer. A running download can be given up by hand (set aside for good). The seed ratio, seed days and stall hours are on the search settings card. The download client lookup moves to acquire.DownloadClientFor, shared by the importer and the lifecycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -630,6 +630,8 @@ export type WantGrab = {
|
||||
progress: number;
|
||||
import_state: ImportState;
|
||||
import_reason: string;
|
||||
// Why an ended download ended (#5523).
|
||||
end_detail: string;
|
||||
imported_at: string | null;
|
||||
imported_files: number;
|
||||
};
|
||||
@@ -710,6 +712,12 @@ export type SearchSettings = {
|
||||
// scan_paths), and the library's folders (#5522).
|
||||
import_root: string;
|
||||
scan_paths: string[];
|
||||
// The download lifecycle (#5523): an imported download seeds to this
|
||||
// ratio or for this many days (0: removed once imported; no time limit),
|
||||
// and one nobody shares is given up after this many hours (0: never).
|
||||
seed_ratio: number;
|
||||
seed_days: number;
|
||||
stall_hours: number;
|
||||
};
|
||||
|
||||
export type WantCounts = {
|
||||
@@ -761,17 +769,42 @@ export type Download = {
|
||||
files: string[];
|
||||
skipped: number;
|
||||
rehomed_from?: string;
|
||||
// Why an ended download ended; for an imported one, its seeding (#5523).
|
||||
end_detail: string;
|
||||
seeding: boolean;
|
||||
ratio: number;
|
||||
seed_released_at: string | null;
|
||||
// What is wrong with it now, if anything.
|
||||
condition: DownloadCondition | null;
|
||||
};
|
||||
|
||||
export type DownloadsPage = { items: Download[]; limit: number; offset: number };
|
||||
// An open condition on a download, from the lifecycle's ledger (#5523).
|
||||
export type DownloadCondition = {
|
||||
trigger: 'no_peers' | 'no_metadata' | 'client_error' | 'client_unreachable' | 'gone' | 'not_removed';
|
||||
detail: string;
|
||||
retries: number;
|
||||
since: string;
|
||||
};
|
||||
|
||||
// A download client not answering now.
|
||||
export type ClientDown = { client: string; detail: string; since: string };
|
||||
|
||||
export type DownloadsPage = {
|
||||
items: Download[];
|
||||
limit: number;
|
||||
offset: number;
|
||||
clients_down: ClientDown[];
|
||||
};
|
||||
|
||||
// A release set aside: by a person, by its files, or by an import's check.
|
||||
export type ReleaseBlock = {
|
||||
info_hash: string;
|
||||
name: string;
|
||||
reason: 'operator' | 'files' | 'import';
|
||||
reason: 'operator' | 'files' | 'import' | 'stalled';
|
||||
detail: string;
|
||||
blocked_at: string;
|
||||
// When a release given up on may be taken again; null is for good.
|
||||
expires_at: string | null;
|
||||
want_title: string;
|
||||
want_artist: string;
|
||||
};
|
||||
|
||||
@@ -160,6 +160,9 @@ export async function putSearchSettings(body: {
|
||||
search_interval_hours: number;
|
||||
allowed_qualities: string[];
|
||||
import_root: string;
|
||||
seed_ratio: number;
|
||||
seed_days: number;
|
||||
stall_hours: number;
|
||||
}): Promise<SearchSettings> {
|
||||
return api.put<SearchSettings>('/api/admin/acquisition/settings', body);
|
||||
}
|
||||
@@ -199,6 +202,12 @@ export async function refuseDownload(id: string): Promise<void> {
|
||||
await api.post(`/api/admin/downloads/${id}/refuse`, {});
|
||||
}
|
||||
|
||||
// A running download given up: the release is set aside for good, the
|
||||
// download removed and the album searched for again (#5523).
|
||||
export async function abandonDownload(id: string): Promise<void> {
|
||||
await api.post(`/api/admin/downloads/${id}/abandon`, {});
|
||||
}
|
||||
|
||||
export async function listReleaseBlocks(offset: number = 0): Promise<ReleaseBlocksPage> {
|
||||
return api.get<ReleaseBlocksPage>(`/api/admin/release-blocks?offset=${offset}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user