Conversation
Contributor
There was a problem hiding this comment.
Sorry @MX-fox, your pull request is larger than the review limit of 150000 diff characters
Contributor
Reviewer's Guide实现一个对进程安全的、就地(in-place)备份/恢复生命周期,引入运行时监督器(runtime supervisor)、事务性的文件恢复日志(journaling)、更严格的备份校验以及具备运行时感知的适配器/进程停机机制,并新增用于备份上传/恢复和状态查询的 API 端点。 进程内运行时备份恢复生命周期的时序图sequenceDiagram
actor User
participant API as sd_api_backup_restore
participant DiceManager
participant RuntimeSupervisor
participant RestoreWorker as restoreWorker
User->>API: POST /sd-api/backup/restore {name,requestId}
API->>DiceManager: ScheduleRestore(name, requestId)
DiceManager-->>API: RestoreOperation{operationId,statusToken}
API->>RuntimeSupervisor: enqueueRestore(operationId)
RuntimeSupervisor-->>API: accepted (true/false)
API-->>User: Response{operationId,statusToken,reloading}
loop restore queue worker
RuntimeSupervisor->>RestoreWorker: restore(ctx, operationId)
RestoreWorker->>DiceManager: Quiesce(ctx)
RestoreWorker->>DiceManager: Finalize(ctx)
RestoreWorker->>DiceManager: PrepareScheduledRestore(DiceManager)
RestoreWorker->>DiceManager: ApplyScheduledRestore()
RestoreWorker->>RuntimeSupervisor: buildValidatedRuntime()
RuntimeSupervisor->>DiceManager: CommitScheduledRestore()
RuntimeSupervisor->>DiceManager: MarkScheduledRestoreSucceeded()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 控制面板 以:
Getting HelpOriginal review guide in EnglishReviewer's GuideImplement a process-safe, in-place backup/restore lifecycle with a runtime supervisor, transactional file restore journaling, stricter backup validation, and runtime-aware adapter/process shutdown, plus new API endpoints for backup upload/restore and status querying. Sequence diagram for in-process runtime backup restore lifecyclesequenceDiagram
actor User
participant API as sd_api_backup_restore
participant DiceManager
participant RuntimeSupervisor
participant RestoreWorker as restoreWorker
User->>API: POST /sd-api/backup/restore {name,requestId}
API->>DiceManager: ScheduleRestore(name, requestId)
DiceManager-->>API: RestoreOperation{operationId,statusToken}
API->>RuntimeSupervisor: enqueueRestore(operationId)
RuntimeSupervisor-->>API: accepted (true/false)
API-->>User: Response{operationId,statusToken,reloading}
loop restore queue worker
RuntimeSupervisor->>RestoreWorker: restore(ctx, operationId)
RestoreWorker->>DiceManager: Quiesce(ctx)
RestoreWorker->>DiceManager: Finalize(ctx)
RestoreWorker->>DiceManager: PrepareScheduledRestore(DiceManager)
RestoreWorker->>DiceManager: ApplyScheduledRestore()
RestoreWorker->>RuntimeSupervisor: buildValidatedRuntime()
RuntimeSupervisor->>DiceManager: CommitScheduledRestore()
RuntimeSupervisor->>DiceManager: MarkScheduledRestoreSucceeded()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
MX-fox
marked this pull request as draft
August 11, 2026 13:33
A timed-out Quiesce/Finalize no longer permanently poisons the shared phase result. Context-only failures can be retried by a later caller with a fresh context, so a slow adapter or JS loop cannot leave the Runtime uncloseable.
- Onebot: protect antPool with a mutex and make isShuttingDown atomic. - Gocq/WalleQ: serialize login index, diceServing, socket and reverse app access. - Minecraft/SealChat: make Reconnecting atomic and guard Socket swaps/snapshots. - Red/Dodo: guard conn/WebSocket/Client access with runtimeMu and snapshots. - Milky/Discord/Kook/Telegram/Slack/Satori shutdown stops closing sessions in place, avoiding writes that race with in-flight handlers.
releaseRetryablePendingRestore now checks journal.json and old-data before ScheduleRestore removes the .restore directory, preserving possible original data copies from interrupted legacy restores.
…aths - Publish backups via temp file + rename so list/clean never observe a half-written archive. - Enforce the same ZIP/path/size limits during creation and keep non-strict backups best-effort for optional files and symlinks. - ScheduleRestore now validates, hashes and copies from one verified fd. - Journal entries re-validate target/rollback/staged paths on read and apply. - Linux uses RENAME_NOREPLACE; import filenames use the full SHA-256. - Rollback ambiguity and pending-missing/rolled_back recovery are handled without invalid state transitions, and rolled-back restores are no longer auto-retried at startup.
- Multiple queued operation IDs are preserved instead of overwriting each other, and the worker observes cancellation between items. - API maintenance drain and adapter RuntimeShutdown calls are bounded by timeouts instead of hanging forever. - ImportBackup no longer holds the global backup mutex while streaming the network request body.
- Close plugin WebSockets once in Finalize instead of per-Dice jsClear. - Dispose the process exit job object so KILL_ON_JOB_CLOSE can reap child processes when a Runtime is torn down. - Clear each Dice's DBOperator reference after closing the manager operator.
- runtimeAuth now follows uiPassword changes and keeps the login salt endpoint correct after password edits. - Restore status tokens are no longer persisted in plaintext; tokens are cached in memory and reissued after restart or expiry. - Replaying an already-succeeded restore returns reloading:false instead of enqueueing an empty run. - Restore legacy delete/download responses keep their old success/error shape, and multipart uploads are bounded.
- cleanupCreate now returns an error, keeps the process file lock when the Runtime fails to stop, and doReboot refuses to start a second process. - Windows fallback ports are propagated to the supervisor/runtime and --address keeps its historical persistence behavior. - force_stop on Android delegates to the injected supervisor stop path. - Dice name validation is platform-aware at startup while restore validation stays strictly portable across operating systems.
- Correct restart-arg test to use the real --hide-ui flag. - Remove unused update listener functions. - Keep the legacy --delay startup log and detect non-directory frontend overwrite in the degraded control plane. - Make backup filenames same-second collision resistant and stop BackupClean from counting temporary/foreign files; log actual delete/skip counts.
- v1 backups without versionCode are accepted again. - Dice.Init tolerates a missing Parent for standalone/test construction. - dboperator drops its package-level singleton path; DBCheck uses a fresh engine instance.
…nits - OfficialQQ RuntimeShutdown snapshots and closes servers/channels once. - BuiltinQQServeProcessKillBase drops the ignored isSync parameter. - directorySize detects Windows reparse points. - BackupInUse takes the backup mutex itself; OpenBackupArchive also compares size and modtime against the validated file.
Use GetVolumeInformation to identify the volume instead of the lexical drive letter, so junction/subst mounts are not mistaken for the same filesystem.
Legacy v1 backups with non-UTF8 entry names are decoded as CP437 before path normalization, preserving compatibility without weakening traversal checks.
MX-fox
force-pushed
the
feat/backup-restore-v2
branch
from
August 15, 2026 14:23
536c7d7 to
64c9b7d
Compare
The Linux-specific rename file was missing syncRestoreDirectoryPath and isLinkedRestorePath after the rebase, breaking dice compilation on Linux CI.
- Remove unused preflight/copy path wrappers after fd-based restore checks. - Rename shadowed journal validation error and avoid variadic errors.Join with a guaranteed nil receiver. - Explicitly discard cleanup errors at process-exit call sites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
引入一个对进程安全的、具备事务性的运行时备份与恢复生命周期机制,包含运行时监管、v2 备份清单,以及用于进程内恢复的健壮安全检查。
New Features:
Bug Fixes:
Enhancements:
Tests:
Original summary in English
Summary by Sourcery
Introduce a process-safe, transactional runtime backup and restore lifecycle with runtime supervision, v2 backup manifests, and robust safety checks for in-process recovery.
New Features:
Bug Fixes:
Enhancements:
Tests: