mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 19:36:20 -05:00
The old sync engine is removed (#998)
* The old sync engine is removed Part 4 of replacing the sync. Since the previous part a secondary copies its primary with rsync, run by the Controller, so nothing used the HTTP engine any more: - the manifest (/api/sync/manifest), the download of a FileGroup's files over HTTP, the copy and import of each synced config, the moving of a replaced file's links, the request, cancel and tick of the old sync; - the API lock that answered 503 SYNCING while that engine ran, its Event, the sync_running flag, the old status record in /api/status and its schema, and the frontend's handling of 503 SYNCING; - their tests. What a primary says about itself (/api/sync/info), the secondary's settings (its primary, the folders it does not copy, Test Connection, the folder chooser), taking the primary's library settings when the API starts, and the daily window of the backup drive stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * The primary's sync info no longer reports the largest FileGroup id Only the old engine read it. Review also found a docstring that still spoke of a manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A sync is announced again Since the Controller runs a sync, nothing sent its events: the old engine did, and the Controller cannot send the API's events (the API is stopped for most of a sync). The API's loop now reads the Controller's record of the last sync and sends one event per finished sync: "Synced N files from the primary" (with the files moved to the trash, or a warning) or "Sync from the primary failed". As before, a sync that changed nothing is not announced (within the window that is every 15 minutes), nor one that was stopped on purpose. What was announced is kept in config/.sync, which a sync never touches, so the restart every sync makes neither repeats nor loses one. Found by review, and by the dead-code check, which saw the two event methods unused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8cfe36b3ea
commit
38885990f6
23 changed files with 354 additions and 1797 deletions
|
|
@ -34,11 +34,6 @@ export class ApiDownError extends Error {
|
|||
|
||||
const apiDownError = new ApiDownError('API is down');
|
||||
|
||||
// A secondary WROLPi refuses requests while it copies its library from its primary. Like a down API, callers
|
||||
// treat it quietly; the app shows the sync's progress instead (see SyncingOverlay).
|
||||
export class SyncingError extends ApiDownError {
|
||||
}
|
||||
|
||||
async function apiCall(url, method, body, ms = 60_000) {
|
||||
let init = {method};
|
||||
if (body !== undefined) {
|
||||
|
|
@ -64,9 +59,6 @@ async function apiCall(url, method, body, ms = 60_000) {
|
|||
let copy = response.clone();
|
||||
const content = await copy.json();
|
||||
const code = content['code'];
|
||||
if (response.status === 503 && code === 'SYNCING') {
|
||||
throw new SyncingError('This WROLPi is syncing from its primary');
|
||||
}
|
||||
console.error('API error response json', content);
|
||||
if (response.status === 403 && code === 'WROL_MODE_ENABLED') {
|
||||
toast({
|
||||
|
|
|
|||
|
|
@ -96,33 +96,6 @@ export const settingsFixture = (overrides = {}) => ({
|
|||
...overrides,
|
||||
});
|
||||
|
||||
/** The `sync` of GET /api/status: a secondary that has never synced. */
|
||||
export const syncStatusFixture = (overrides = {}) => ({
|
||||
state: 'idle',
|
||||
phase: null,
|
||||
requested: false,
|
||||
force: false,
|
||||
cancel_requested: false,
|
||||
started_at: null,
|
||||
finished_at: null,
|
||||
last_success_at: null,
|
||||
last_error: null,
|
||||
last_skip_reason: null,
|
||||
primary_url: null,
|
||||
primary_version: null,
|
||||
groups_seen: 0,
|
||||
max_id: 0,
|
||||
files_checked: 0,
|
||||
files_to_download: 0,
|
||||
files_downloaded: 0,
|
||||
bytes_downloaded: 0,
|
||||
files_failed: 0,
|
||||
files_excluded: 0,
|
||||
configs_imported: [],
|
||||
disk_full: false,
|
||||
...overrides,
|
||||
});
|
||||
|
||||
/** GET /controller/api/sync/status: a secondary's sync that has never run (controller/lib/sync.py). */
|
||||
export const controllerSyncStatusFixture = (overrides = {}) => ({
|
||||
state: 'idle',
|
||||
|
|
@ -198,8 +171,6 @@ export const statusFixture = (overrides = {}) => ({
|
|||
memory_stats: {total: 4000000000, used: 1000000000, free: 3000000000, cached: 500000000},
|
||||
processes_stats: [],
|
||||
sanic_workers: {},
|
||||
// A secondary's sync (wrolpi.sync); idle on a primary.
|
||||
sync: syncStatusFixture(),
|
||||
// A backup to a second drive (wrolpi.sync.backup); idle without one.
|
||||
backup: backupStatusFixture(),
|
||||
version: '1.0.0',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue