* [pbs-devel] [PATCH proxmox-backup] datastore: replace deprecated `archive_type` function
@ 2024-07-03 10:11 Christian Ebner
2024-07-12 12:02 ` [pbs-devel] applied: " Wolfgang Bumiller
0 siblings, 1 reply; 2+ messages in thread
From: Christian Ebner @ 2024-07-03 10:11 UTC (permalink / raw)
To: pbs-devel
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>
---
pbs-datastore/src/datastore.rs | 8 ++++----
pbs-datastore/src/snapshot_reader.rs | 21 ++++++++++++---------
proxmox-backup-client/src/main.rs | 4 ++--
src/api2/backup/mod.rs | 4 ++--
src/api2/reader/mod.rs | 4 ++--
src/api2/tape/restore.rs | 4 ++--
src/backup/verify.rs | 4 ++--
src/server/pull.rs | 6 +++---
8 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index f95da7615..3699eb52f 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -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
{
@@ -1012,7 +1012,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)
diff --git a/pbs-datastore/src/snapshot_reader.rs b/pbs-datastore/src/snapshot_reader.rs
index ec7a48e54..f9c772079 100644
--- a/pbs-datastore/src/snapshot_reader.rs
+++ b/pbs-datastore/src/snapshot_reader.rs
@@ -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());
}
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 003abaef2..6a7d09047 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -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") {
diff --git a/src/api2/backup/mod.rs b/src/api2/backup/mod.rs
index 013043dd0..915fb2a84 100644
--- a/src/api2/backup/mod.rs
+++ b/src/api2/backup/mod.rs
@@ -23,7 +23,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};
use proxmox_rest_server::{H2Service, WorkerTask};
@@ -839,7 +839,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))
diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs
index 42b428385..23492f64c 100644
--- a/src/api2/reader/mod.rs
+++ b/src/api2/reader/mod.rs
@@ -23,7 +23,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;
use proxmox_rest_server::{H2Service, WorkerTask};
@@ -261,7 +261,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))
diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs
index 7b96acb6c..79200d1b9 100644
--- a/src/api2/tape/restore.rs
+++ b/src/api2/tape/restore.rs
@@ -28,7 +28,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,
@@ -1100,7 +1100,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)?)
}
diff --git a/src/backup/verify.rs b/src/backup/verify.rs
index c972e5328..8dde7dacc 100644
--- a/src/backup/verify.rs
+++ b/src/backup/verify.rs
@@ -14,7 +14,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 proxmox_sys::fs::lock_dir_noblock_shared;
@@ -407,7 +407,7 @@ pub fn verify_backup_dir_with_lock(
for info in manifest.files() {
let result = proxmox_lang::try_block!({
task_log!(verify_worker.worker, " 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),
diff --git a/src/server/pull.rs b/src/server/pull.rs
index 14744e9c8..d144e2f2d 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -27,7 +27,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::{
@@ -753,7 +753,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)
@@ -874,7 +874,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();
--
2.39.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup] datastore: replace deprecated `archive_type` function
2024-07-03 10:11 [pbs-devel] [PATCH proxmox-backup] datastore: replace deprecated `archive_type` function Christian Ebner
@ 2024-07-12 12:02 ` Wolfgang Bumiller
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2024-07-12 12:02 UTC (permalink / raw)
To: Christian Ebner; +Cc: pbs-devel
applied, thanks
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-12 12:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-03 10:11 [pbs-devel] [PATCH proxmox-backup] datastore: replace deprecated `archive_type` function Christian Ebner
2024-07-12 12:02 ` [pbs-devel] applied: " Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox