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