datastore: replace deprecated archive_type
function
Commit ea584a75
"move more api types for the client" deprecated
the `archive_type` function in favor of the associated function
`ArchiveType::from_path`.
Replace all remaining callers of the deprecated function with its
replacement.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
[WB: and remove the deprecated function]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
c052040028
commit
6e3f844f9a
@ -29,7 +29,7 @@ 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::{archive_type, ArchiveType};
|
||||
use crate::manifest::ArchiveType;
|
||||
use crate::task_tracking::{self, update_active_operations};
|
||||
use crate::DataBlob;
|
||||
|
||||
@ -377,7 +377,7 @@ impl DataStore {
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let filename = filename.as_ref();
|
||||
let out: Box<dyn IndexFile + Send> = match archive_type(filename)? {
|
||||
let out: Box<dyn IndexFile + Send> = match ArchiveType::from_path(filename)? {
|
||||
ArchiveType::DynamicIndex => Box::new(self.open_dynamic_reader(filename)?),
|
||||
ArchiveType::FixedIndex => Box::new(self.open_fixed_reader(filename)?),
|
||||
_ => bail!("cannot open index file of unknown type: {:?}", filename),
|
||||
@ -936,7 +936,7 @@ impl DataStore {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if let Ok(archive_type) = archive_type(&path) {
|
||||
if let Ok(archive_type) = ArchiveType::from_path(&path) {
|
||||
if archive_type == ArchiveType::FixedIndex
|
||||
|| archive_type == ArchiveType::DynamicIndex
|
||||
{
|
||||
@ -1011,7 +1011,7 @@ impl DataStore {
|
||||
|
||||
match std::fs::File::open(&img) {
|
||||
Ok(file) => {
|
||||
if let Ok(archive_type) = archive_type(&img) {
|
||||
if let Ok(archive_type) = ArchiveType::from_path(&img) {
|
||||
if archive_type == ArchiveType::FixedIndex {
|
||||
let index = FixedIndexReader::new(file).map_err(|e| {
|
||||
format_err!("can't read index '{}' - {}", img.to_string_lossy(), e)
|
||||
|
@ -76,11 +76,6 @@ impl ArchiveType {
|
||||
}
|
||||
}
|
||||
|
||||
//#[deprecated(note = "use ArchivType::from_path instead")] later...
|
||||
pub fn archive_type<P: AsRef<Path>>(archive_name: P) -> Result<ArchiveType, Error> {
|
||||
ArchiveType::from_path(archive_name)
|
||||
}
|
||||
|
||||
impl BackupManifest {
|
||||
pub fn new(snapshot: pbs_api_types::BackupDir) -> Self {
|
||||
Self {
|
||||
|
@ -14,7 +14,7 @@ use crate::backup_info::BackupDir;
|
||||
use crate::dynamic_index::DynamicIndexReader;
|
||||
use crate::fixed_index::FixedIndexReader;
|
||||
use crate::index::IndexFile;
|
||||
use crate::manifest::{archive_type, ArchiveType, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use crate::manifest::{ArchiveType, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use crate::DataStore;
|
||||
|
||||
/// Helper to access the contents of a datastore backup snapshot
|
||||
@ -138,13 +138,16 @@ impl<'a, F: Fn(&[u8; 32]) -> bool> Iterator for SnapshotChunkIterator<'a, F> {
|
||||
if self.current_index.is_none() {
|
||||
if let Some(filename) = self.todo_list.pop() {
|
||||
let file = self.snapshot_reader.open_file(&filename)?;
|
||||
let index: Box<dyn IndexFile + Send> = match archive_type(&filename)? {
|
||||
ArchiveType::FixedIndex => Box::new(FixedIndexReader::new(file)?),
|
||||
ArchiveType::DynamicIndex => Box::new(DynamicIndexReader::new(file)?),
|
||||
_ => bail!(
|
||||
"SnapshotChunkIterator: got unknown file type - internal error"
|
||||
),
|
||||
};
|
||||
let index: Box<dyn IndexFile + Send> =
|
||||
match ArchiveType::from_path(&filename)? {
|
||||
ArchiveType::FixedIndex => Box::new(FixedIndexReader::new(file)?),
|
||||
ArchiveType::DynamicIndex => {
|
||||
Box::new(DynamicIndexReader::new(file)?)
|
||||
}
|
||||
_ => bail!(
|
||||
"SnapshotChunkIterator: got unknown file type - internal error"
|
||||
),
|
||||
};
|
||||
|
||||
let datastore = DataStore::lookup_datastore(
|
||||
self.snapshot_reader.datastore_name(),
|
||||
@ -178,7 +181,7 @@ impl<'a, F: Fn(&[u8; 32]) -> bool> SnapshotChunkIterator<'a, F> {
|
||||
let mut todo_list = Vec::new();
|
||||
|
||||
for filename in snapshot_reader.file_list() {
|
||||
match archive_type(filename)? {
|
||||
match ArchiveType::from_path(filename)? {
|
||||
ArchiveType::FixedIndex | ArchiveType::DynamicIndex => {
|
||||
todo_list.push(filename.to_owned());
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ use pbs_datastore::dynamic_index::{BufferedDynamicReader, DynamicIndexReader, Lo
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{
|
||||
archive_type, ArchiveType, BackupManifest, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME,
|
||||
ArchiveType, BackupManifest, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME,
|
||||
};
|
||||
use pbs_datastore::read_chunk::AsyncReadChunk;
|
||||
use pbs_datastore::CATALOG_NAME;
|
||||
@ -1361,7 +1361,7 @@ async fn dump_image<W: Write>(
|
||||
|
||||
fn parse_archive_type(name: &str) -> (String, ArchiveType) {
|
||||
if name.ends_with(".didx") || name.ends_with(".fidx") || name.ends_with(".blob") {
|
||||
(name.into(), archive_type(name).unwrap())
|
||||
(name.into(), ArchiveType::from_path(name).unwrap())
|
||||
} else if has_pxar_filename_extension(name, false) {
|
||||
(format!("{}.didx", name), ArchiveType::DynamicIndex)
|
||||
} else if name.ends_with(".img") {
|
||||
|
@ -25,7 +25,7 @@ use pbs_api_types::{
|
||||
};
|
||||
use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{archive_type, ArchiveType};
|
||||
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};
|
||||
|
||||
@ -842,7 +842,7 @@ fn download_previous(
|
||||
path.push(&archive_name);
|
||||
|
||||
{
|
||||
let index: Option<Box<dyn IndexFile>> = match archive_type(&archive_name)? {
|
||||
let index: Option<Box<dyn IndexFile>> = match ArchiveType::from_path(&archive_name)? {
|
||||
ArchiveType::FixedIndex => {
|
||||
let index = env.datastore.open_fixed_reader(&path)?;
|
||||
Some(Box::new(index))
|
||||
|
@ -25,7 +25,7 @@ use pbs_api_types::{
|
||||
};
|
||||
use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{archive_type, ArchiveType};
|
||||
use pbs_datastore::manifest::ArchiveType;
|
||||
use pbs_datastore::{DataStore, PROXMOX_BACKUP_READER_PROTOCOL_ID_V1};
|
||||
use pbs_tools::json::required_string_param;
|
||||
|
||||
@ -263,7 +263,7 @@ fn download_file(
|
||||
|
||||
env.log(format!("download {:?}", path.clone()));
|
||||
|
||||
let index: Option<Box<dyn IndexFile + Send>> = match archive_type(&file_name)? {
|
||||
let index: Option<Box<dyn IndexFile + Send>> = match ArchiveType::from_path(&file_name)? {
|
||||
ArchiveType::FixedIndex => {
|
||||
let index = env.datastore.open_fixed_reader(&path)?;
|
||||
Some(Box::new(index))
|
||||
|
@ -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::{archive_type, ArchiveType, BackupManifest, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::manifest::{ArchiveType, BackupManifest, MANIFEST_BLOB_NAME};
|
||||
use pbs_datastore::{DataBlob, DataStore};
|
||||
use pbs_tape::{
|
||||
BlockReadError, MediaContentHeader, TapeRead, PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0,
|
||||
@ -1061,7 +1061,7 @@ fn restore_snapshots_to_tmpdir(
|
||||
let mut archive_path = tmp_path.to_owned();
|
||||
archive_path.push(&item.filename);
|
||||
|
||||
let index: Box<dyn IndexFile> = match archive_type(&item.filename)? {
|
||||
let index: Box<dyn IndexFile> = match ArchiveType::from_path(&item.filename)? {
|
||||
ArchiveType::DynamicIndex => {
|
||||
Box::new(DynamicIndexReader::open(&archive_path)?)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use pbs_api_types::{
|
||||
};
|
||||
use pbs_datastore::backup_info::{BackupDir, BackupGroup, BackupInfo};
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, FileInfo};
|
||||
use pbs_datastore::manifest::{ArchiveType, BackupManifest, FileInfo};
|
||||
use pbs_datastore::{DataBlob, DataStore, StoreProgress};
|
||||
|
||||
use crate::tools::parallel_handler::ParallelHandler;
|
||||
@ -371,7 +371,7 @@ pub fn verify_backup_dir_with_lock(
|
||||
for info in manifest.files() {
|
||||
let result = proxmox_lang::try_block!({
|
||||
info!(" check {}", info.filename);
|
||||
match archive_type(&info.filename)? {
|
||||
match ArchiveType::from_path(&info.filename)? {
|
||||
ArchiveType::FixedIndex => verify_fixed_index(verify_worker, backup_dir, info),
|
||||
ArchiveType::DynamicIndex => verify_dynamic_index(verify_worker, backup_dir, info),
|
||||
ArchiveType::Blob => verify_blob(backup_dir, info),
|
||||
|
@ -26,7 +26,7 @@ use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{
|
||||
archive_type, ArchiveType, BackupManifest, FileInfo, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME,
|
||||
ArchiveType, BackupManifest, FileInfo, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME,
|
||||
};
|
||||
use pbs_datastore::read_chunk::AsyncReadChunk;
|
||||
use pbs_datastore::{
|
||||
@ -709,7 +709,7 @@ async fn pull_single_archive<'a>(
|
||||
|
||||
let mut tmpfile = std::fs::OpenOptions::new().read(true).open(&tmp_path)?;
|
||||
|
||||
match archive_type(archive_name)? {
|
||||
match ArchiveType::from_path(archive_name)? {
|
||||
ArchiveType::DynamicIndex => {
|
||||
let index = DynamicIndexReader::new(tmpfile).map_err(|err| {
|
||||
format_err!("unable to read dynamic index {:?} - {}", tmp_path, err)
|
||||
@ -825,7 +825,7 @@ async fn pull_snapshot<'a>(
|
||||
path.push(&item.filename);
|
||||
|
||||
if path.exists() {
|
||||
match archive_type(&item.filename)? {
|
||||
match ArchiveType::from_path(&item.filename)? {
|
||||
ArchiveType::DynamicIndex => {
|
||||
let index = DynamicIndexReader::open(&path)?;
|
||||
let (csum, size) = index.compute_csum();
|
||||
|
Loading…
Reference in New Issue
Block a user