ic_backup/ops/persistence/
mod.rs1mod artifact_commit;
4mod attempt_journal;
5mod download_journal;
6mod execution_progress;
7mod execution_settlement;
8mod execution_workflow;
9mod immutable_record;
10mod journal_lock;
11mod journal_path;
12pub(crate) mod json;
13mod layout_lifetime;
14mod operation_plan;
15mod restore_reference_release;
16mod restore_safety;
17
18pub(crate) use artifact_commit::commit_artifact_directory;
19pub use attempt_journal::{AttemptJournalError, AttemptJournalGuard};
20pub use download_journal::{
21 DownloadIntegrityError, DownloadJournalError, DownloadJournalGuard, DownloadManifestError,
22 read_download_manifest,
23};
24#[cfg(unix)]
25pub use download_journal::{
26 IcSnapshotArtifactError, IcSnapshotArtifactWriter, IcSnapshotDataUploadPreparationError,
27 IcSnapshotUploadArtifactError,
28};
29pub use execution_progress::{ExecutionProgressPersistenceError, read_execution_progress};
30pub use execution_settlement::{
31 ExecutionSettlementCheckpointError, ExecutionSettlementPersistenceError,
32 read_execution_settlement, reconcile_execution_settlement, replay_execution_settlement,
33};
34pub(crate) use execution_workflow::read_execution_stage_occupancy;
35pub use execution_workflow::{
36 ExecutionStageCheckpointError, ExecutionStageGuard, ExecutionStagePreparationError,
37 ExecutionStageResumeError, ExecutionStageSettlementView, ExecutionWorkflowPersistenceError,
38 ExecutionWorkflowProgressError, ExecutionWorkflowSettlementView, create_execution_workflow,
39 read_complete_execution_workflow, read_complete_execution_workflow_locked,
40 read_execution_workflow, read_execution_workflow_progress,
41};
42pub use journal_lock::{JournalLock, JournalLockError};
43pub(crate) use json::read_json;
44pub use layout_lifetime::{BackupLayoutGuard, MAX_RESTORE_REFERENCE_BYTES};
45pub use operation_plan::{
46 OperationPlanPersistenceError, create_operation_plan, read_operation_plan,
47};
48pub use restore_reference_release::{
49 MAX_RESTORE_TERMINAL_BYTES, RestoreReferenceReleaseError, RestoreReferenceReleaseOutcome,
50 RestoreTerminalEvidenceProvider,
51};
52pub use restore_safety::{
53 RestoreSafetyPersistenceError, create_restore_safety_requirement,
54 read_restore_safety_requirement,
55};
56
57use crate::{model::artifacts::ChecksumError, ops::artifacts::ArtifactError};
58use std::io;
59use thiserror::Error;
60
61#[derive(Debug, Error)]
63pub enum PersistenceError {
64 #[error(
67 "retired application state at {path:?}; retain all evidence and recover with ic-backup 0.57.1 and the original integration before upgrading"
68 )]
69 RetiredApplicationState {
70 path: std::path::PathBuf,
72 },
73 #[error("backup layout changed while held: {path:?}")]
75 LayoutChanged {
76 path: std::path::PathBuf,
78 },
79 #[error("unsafe restore reference entry: {path:?}")]
81 InvalidRestoreReferences {
82 path: std::path::PathBuf,
84 },
85 #[error(transparent)]
87 RestoreReference(#[from] crate::model::restore_references::RestoreReferenceError),
88 #[error(transparent)]
91 Io(#[from] io::Error),
92 #[error(transparent)]
95 Publication(#[from] ic_host_fs::durable::NamedWriteError<io::Error>),
96 #[error(transparent)]
98 Json(#[from] serde_json::Error),
99 #[error("record exceeds byte limit {limit}")]
101 RecordTooLarge {
102 limit: u64,
104 },
105 #[error(transparent)]
107 Artifact(#[from] ArtifactError),
108 #[error(transparent)]
110 Checksum(#[from] ChecksumError),
111 #[error("artifact commit paths must be distinct siblings: {temporary}, {canonical}")]
113 ArtifactCommitPathMismatch {
114 temporary: String,
116 canonical: String,
118 },
119 #[error("artifact commit has conflicting paths: {temporary}, {canonical}")]
121 ArtifactCommitPathConflict {
122 temporary: String,
124 canonical: String,
126 },
127 #[error("artifact commit is missing both paths: {temporary}, {canonical}")]
129 ArtifactCommitPathMissing {
130 temporary: String,
132 canonical: String,
134 },
135 #[error("durable artifact publication is unsupported on {platform}")]
137 ArtifactCommitUnsupportedPlatform {
138 platform: &'static str,
140 },
141 #[error("unsupported artifact entry at {path}: {kind}")]
143 UnsupportedArtifactEntry {
144 path: String,
146 kind: String,
148 },
149}
150
151#[cfg(unix)]
153fn unsafe_entry_kind(path: &std::path::Path) -> &'static str {
154 match std::fs::symlink_metadata(path) {
155 Ok(metadata) if metadata.file_type().is_symlink() => "Symlink",
156 Ok(metadata) if metadata.is_dir() => "Directory",
157 _ => "Special",
158 }
159}