mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-02 19:08:03 +00:00
datastore: move ArchiveType
to api types
Moving the `ArchiveType` to avoid crate dependencies on `pbs-datastore`. In preparation for introducing a dedicated `BackupArchiveName` api type, allowing to set the corresponding archive type variant when parsing the archive name based on it's filename. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
cbf7bbefb7
commit
e932ec101e
@ -1,5 +1,5 @@
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use const_format::concatcp;
|
||||
@ -1644,3 +1644,24 @@ impl BackupGroupDeleteStats {
|
||||
self.protected_snapshots += 1;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
/// Allowed variants of backup archives to be contained in a snapshot's manifest
|
||||
pub enum ArchiveType {
|
||||
FixedIndex,
|
||||
DynamicIndex,
|
||||
Blob,
|
||||
}
|
||||
|
||||
impl ArchiveType {
|
||||
pub fn from_path(archive_name: impl AsRef<Path>) -> Result<Self, Error> {
|
||||
let archive_name = archive_name.as_ref();
|
||||
let archive_type = match archive_name.extension().and_then(|ext| ext.to_str()) {
|
||||
Some("didx") => ArchiveType::DynamicIndex,
|
||||
Some("fidx") => ArchiveType::FixedIndex,
|
||||
Some("blob") => ArchiveType::Blob,
|
||||
_ => bail!("unknown archive type: {archive_name:?}"),
|
||||
};
|
||||
Ok(archive_type)
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ use tokio::io::AsyncReadExt;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
use pbs_api_types::{BackupDir, BackupNamespace};
|
||||
use pbs_api_types::{ArchiveType, BackupDir, BackupNamespace};
|
||||
use pbs_datastore::data_blob::{ChunkInfo, DataBlob, DataChunkBuilder};
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{ArchiveType, BackupManifest, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::manifest::{BackupManifest, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::{CATALOG_NAME, PROXMOX_BACKUP_PROTOCOL_ID_V1};
|
||||
use pbs_tools::crypt_config::CryptConfig;
|
||||
|
||||
|
@ -18,9 +18,9 @@ use proxmox_sys::process_locker::ProcessLockSharedGuard;
|
||||
use proxmox_worker_task::WorkerTaskContext;
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, BackupGroupDeleteStats, BackupNamespace, BackupType, ChunkOrder, DataStoreConfig,
|
||||
DatastoreFSyncLevel, DatastoreTuning, GarbageCollectionStatus, MaintenanceMode,
|
||||
MaintenanceType, Operation, UPID,
|
||||
ArchiveType, Authid, BackupGroupDeleteStats, BackupNamespace, BackupType, ChunkOrder,
|
||||
DataStoreConfig, DatastoreFSyncLevel, DatastoreTuning, GarbageCollectionStatus,
|
||||
MaintenanceMode, MaintenanceType, Operation, UPID,
|
||||
};
|
||||
|
||||
use crate::backup_info::{BackupDir, BackupGroup};
|
||||
@ -29,7 +29,6 @@ use crate::dynamic_index::{DynamicIndexReader, DynamicIndexWriter};
|
||||
use crate::fixed_index::{FixedIndexReader, FixedIndexWriter};
|
||||
use crate::hierarchy::{ListGroups, ListGroupsType, ListNamespaces, ListNamespacesRecursive};
|
||||
use crate::index::IndexFile;
|
||||
use crate::manifest::ArchiveType;
|
||||
use crate::task_tracking::{self, update_active_operations};
|
||||
use crate::DataBlob;
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use pbs_api_types::{BackupType, CryptMode, Fingerprint};
|
||||
use pbs_api_types::{ArchiveType, BackupType, CryptMode, Fingerprint};
|
||||
use pbs_tools::crypt_config::CryptConfig;
|
||||
|
||||
pub const MANIFEST_BLOB_NAME: &str = "index.json.blob";
|
||||
@ -56,26 +54,6 @@ pub struct BackupManifest {
|
||||
pub signature: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub enum ArchiveType {
|
||||
FixedIndex,
|
||||
DynamicIndex,
|
||||
Blob,
|
||||
}
|
||||
|
||||
impl ArchiveType {
|
||||
pub fn from_path(archive_name: impl AsRef<Path>) -> Result<Self, Error> {
|
||||
let archive_name = archive_name.as_ref();
|
||||
let archive_type = match archive_name.extension().and_then(|ext| ext.to_str()) {
|
||||
Some("didx") => ArchiveType::DynamicIndex,
|
||||
Some("fidx") => ArchiveType::FixedIndex,
|
||||
Some("blob") => ArchiveType::Blob,
|
||||
_ => bail!("unknown archive type: {:?}", archive_name),
|
||||
};
|
||||
Ok(archive_type)
|
||||
}
|
||||
}
|
||||
|
||||
impl BackupManifest {
|
||||
pub fn new(snapshot: pbs_api_types::BackupDir) -> Self {
|
||||
Self {
|
||||
|
@ -8,13 +8,13 @@ use nix::dir::Dir;
|
||||
|
||||
use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
|
||||
use pbs_api_types::{print_store_and_ns, BackupNamespace, Operation};
|
||||
use pbs_api_types::{print_store_and_ns, ArchiveType, BackupNamespace, Operation};
|
||||
|
||||
use crate::backup_info::BackupDir;
|
||||
use crate::dynamic_index::DynamicIndexReader;
|
||||
use crate::fixed_index::FixedIndexReader;
|
||||
use crate::index::IndexFile;
|
||||
use crate::manifest::{ArchiveType, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use crate::manifest::{CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use crate::DataStore;
|
||||
|
||||
/// Helper to access the contents of a datastore backup snapshot
|
||||
|
@ -25,10 +25,10 @@ use pxar::accessor::aio::Accessor;
|
||||
use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, BackupDir, BackupGroup, BackupNamespace, BackupPart, BackupType, ClientRateLimitConfig,
|
||||
CryptMode, Fingerprint, GroupListItem, PruneJobOptions, PruneListItem, RateLimitConfig,
|
||||
SnapshotListItem, StorageStatus, BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA,
|
||||
BACKUP_TYPE_SCHEMA,
|
||||
ArchiveType, Authid, BackupDir, BackupGroup, BackupNamespace, BackupPart, BackupType,
|
||||
ClientRateLimitConfig, CryptMode, Fingerprint, GroupListItem, PruneJobOptions, PruneListItem,
|
||||
RateLimitConfig, SnapshotListItem, StorageStatus, BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA,
|
||||
BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA,
|
||||
};
|
||||
use pbs_client::catalog_shell::Shell;
|
||||
use pbs_client::pxar::{ErrorHandler as PxarErrorHandler, MetadataArchiveReader, PxarPrevRef};
|
||||
@ -54,9 +54,7 @@ use pbs_datastore::chunk_store::verify_chunk_size;
|
||||
use pbs_datastore::dynamic_index::{BufferedDynamicReader, DynamicIndexReader, LocalDynamicReadAt};
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{
|
||||
ArchiveType, BackupManifest, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME,
|
||||
};
|
||||
use pbs_datastore::manifest::{BackupManifest, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::read_chunk::AsyncReadChunk;
|
||||
use pbs_datastore::CATALOG_NAME;
|
||||
use pbs_key_config::{decrypt_key, rsa_encrypt_key_config, KeyConfig};
|
||||
|
@ -19,13 +19,12 @@ use proxmox_sortable_macro::sortable;
|
||||
use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, BackupNamespace, BackupType, Operation, SnapshotVerifyState, VerifyState,
|
||||
ArchiveType, Authid, BackupNamespace, BackupType, Operation, SnapshotVerifyState, VerifyState,
|
||||
BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA,
|
||||
BACKUP_TYPE_SCHEMA, CHUNK_DIGEST_SCHEMA, DATASTORE_SCHEMA, PRIV_DATASTORE_BACKUP,
|
||||
};
|
||||
use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::ArchiveType;
|
||||
use pbs_datastore::{DataStore, PROXMOX_BACKUP_PROTOCOL_ID_V1};
|
||||
use pbs_tools::json::{required_array_param, required_integer_param, required_string_param};
|
||||
|
||||
|
@ -19,13 +19,12 @@ use proxmox_sortable_macro::sortable;
|
||||
use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, Operation, BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA,
|
||||
BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, CHUNK_DIGEST_SCHEMA, DATASTORE_SCHEMA,
|
||||
PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_READ,
|
||||
ArchiveType, Authid, Operation, BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA,
|
||||
BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, CHUNK_DIGEST_SCHEMA,
|
||||
DATASTORE_SCHEMA, PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_READ,
|
||||
};
|
||||
use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::ArchiveType;
|
||||
use pbs_datastore::{DataStore, PROXMOX_BACKUP_READER_PROTOCOL_ID_V1};
|
||||
use pbs_tools::json::required_string_param;
|
||||
|
||||
|
@ -19,10 +19,10 @@ use proxmox_uuid::Uuid;
|
||||
use proxmox_worker_task::WorkerTaskContext;
|
||||
|
||||
use pbs_api_types::{
|
||||
parse_ns_and_snapshot, print_ns_and_snapshot, Authid, BackupDir, BackupNamespace, CryptMode,
|
||||
NotificationMode, Operation, TapeRestoreNamespace, Userid, DATASTORE_MAP_ARRAY_SCHEMA,
|
||||
DATASTORE_MAP_LIST_SCHEMA, DRIVE_NAME_SCHEMA, MAX_NAMESPACE_DEPTH, PRIV_DATASTORE_BACKUP,
|
||||
PRIV_DATASTORE_MODIFY, PRIV_TAPE_READ, TAPE_RESTORE_NAMESPACE_SCHEMA,
|
||||
parse_ns_and_snapshot, print_ns_and_snapshot, ArchiveType, Authid, BackupDir, BackupNamespace,
|
||||
CryptMode, NotificationMode, Operation, TapeRestoreNamespace, Userid,
|
||||
DATASTORE_MAP_ARRAY_SCHEMA, DATASTORE_MAP_LIST_SCHEMA, DRIVE_NAME_SCHEMA, MAX_NAMESPACE_DEPTH,
|
||||
PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, PRIV_TAPE_READ, TAPE_RESTORE_NAMESPACE_SCHEMA,
|
||||
TAPE_RESTORE_SNAPSHOT_SCHEMA, UPID_SCHEMA,
|
||||
};
|
||||
use pbs_client::pxar::tools::handle_root_with_optional_format_version_prelude;
|
||||
@ -30,7 +30,7 @@ use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{ArchiveType, BackupManifest, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::manifest::{BackupManifest, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::{DataBlob, DataStore};
|
||||
use pbs_tape::{
|
||||
BlockReadError, MediaContentHeader, TapeRead, PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0,
|
||||
|
@ -11,12 +11,13 @@ use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
use proxmox_worker_task::WorkerTaskContext;
|
||||
|
||||
use pbs_api_types::{
|
||||
print_ns_and_snapshot, print_store_and_ns, Authid, BackupNamespace, BackupType, CryptMode,
|
||||
SnapshotVerifyState, VerifyState, PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_VERIFY, UPID,
|
||||
print_ns_and_snapshot, print_store_and_ns, ArchiveType, Authid, BackupNamespace, BackupType,
|
||||
CryptMode, SnapshotVerifyState, VerifyState, PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_VERIFY,
|
||||
UPID,
|
||||
};
|
||||
use pbs_datastore::backup_info::{BackupDir, BackupGroup, BackupInfo};
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{ArchiveType, BackupManifest, FileInfo};
|
||||
use pbs_datastore::manifest::{BackupManifest, FileInfo};
|
||||
use pbs_datastore::{DataBlob, DataStore, StoreProgress};
|
||||
|
||||
use crate::tools::parallel_handler::ParallelHandler;
|
||||
|
@ -11,8 +11,9 @@ use proxmox_human_byte::HumanByte;
|
||||
use tracing::info;
|
||||
|
||||
use pbs_api_types::{
|
||||
print_store_and_ns, Authid, BackupDir, BackupGroup, BackupNamespace, GroupFilter, Operation,
|
||||
RateLimitConfig, Remote, MAX_NAMESPACE_DEPTH, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP,
|
||||
print_store_and_ns, ArchiveType, Authid, BackupDir, BackupGroup, BackupNamespace, GroupFilter,
|
||||
Operation, RateLimitConfig, Remote, MAX_NAMESPACE_DEPTH, PRIV_DATASTORE_AUDIT,
|
||||
PRIV_DATASTORE_BACKUP,
|
||||
};
|
||||
use pbs_client::BackupRepository;
|
||||
use pbs_config::CachedUserInfo;
|
||||
@ -20,9 +21,7 @@ use pbs_datastore::data_blob::DataBlob;
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{
|
||||
ArchiveType, BackupManifest, FileInfo, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME,
|
||||
};
|
||||
use pbs_datastore::manifest::{BackupManifest, FileInfo, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::read_chunk::AsyncReadChunk;
|
||||
use pbs_datastore::{check_backup_owner, DataStore, StoreProgress};
|
||||
use pbs_tools::sha::sha256;
|
||||
|
@ -10,7 +10,7 @@ use tokio_stream::wrappers::ReceiverStream;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use pbs_api_types::{
|
||||
print_store_and_ns, ApiVersion, ApiVersionInfo, Authid, BackupDir, BackupGroup,
|
||||
print_store_and_ns, ApiVersion, ApiVersionInfo, ArchiveType, Authid, BackupDir, BackupGroup,
|
||||
BackupGroupDeleteStats, BackupNamespace, GroupFilter, GroupListItem, NamespaceListItem,
|
||||
Operation, RateLimitConfig, Remote, SnapshotListItem, PRIV_DATASTORE_BACKUP,
|
||||
PRIV_DATASTORE_READ, PRIV_REMOTE_DATASTORE_BACKUP, PRIV_REMOTE_DATASTORE_MODIFY,
|
||||
@ -22,7 +22,7 @@ use pbs_datastore::data_blob::ChunkInfo;
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{ArchiveType, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::manifest::{CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::read_chunk::AsyncReadChunk;
|
||||
use pbs_datastore::{DataStore, StoreProgress};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user