add pbs-tools subcrate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
use crate::tools;
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use std::os::unix::io::RawFd;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::api2::types::{
|
||||
BACKUP_ID_REGEX,
|
||||
@ -81,7 +79,7 @@ impl BackupGroup {
|
||||
let mut path = base_path.to_owned();
|
||||
path.push(self.group_path());
|
||||
|
||||
tools::scandir(
|
||||
pbs_tools::fs::scandir(
|
||||
libc::AT_FDCWD,
|
||||
&path,
|
||||
&BACKUP_DATE_REGEX,
|
||||
@ -108,7 +106,7 @@ impl BackupGroup {
|
||||
let mut path = base_path.to_owned();
|
||||
path.push(self.group_path());
|
||||
|
||||
tools::scandir(
|
||||
pbs_tools::fs::scandir(
|
||||
libc::AT_FDCWD,
|
||||
&path,
|
||||
&BACKUP_DATE_REGEX,
|
||||
@ -342,7 +340,7 @@ impl BackupInfo {
|
||||
pub fn list_backup_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
tools::scandir(
|
||||
pbs_tools::fs::scandir(
|
||||
libc::AT_FDCWD,
|
||||
base_path,
|
||||
&BACKUP_TYPE_REGEX,
|
||||
@ -350,7 +348,7 @@ impl BackupInfo {
|
||||
if file_type != nix::dir::Type::Directory {
|
||||
return Ok(());
|
||||
}
|
||||
tools::scandir(
|
||||
pbs_tools::fs::scandir(
|
||||
l0_fd,
|
||||
backup_type,
|
||||
&BACKUP_ID_REGEX,
|
||||
@ -384,7 +382,7 @@ fn list_backup_files<P: ?Sized + nix::NixPath>(
|
||||
) -> Result<Vec<String>, Error> {
|
||||
let mut files = vec![];
|
||||
|
||||
tools::scandir(dirfd, path, &BACKUP_FILE_REGEX, |_, filename, file_type| {
|
||||
pbs_tools::fs::scandir(dirfd, path, &BACKUP_FILE_REGEX, |_, filename, file_type| {
|
||||
if file_type != nix::dir::Type::File {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -2,8 +2,9 @@ use anyhow::{Error};
|
||||
use std::sync::Arc;
|
||||
use std::io::Read;
|
||||
|
||||
use pbs_tools::borrow::Tied;
|
||||
|
||||
use super::CryptConfig;
|
||||
use crate::tools::borrow::Tied;
|
||||
|
||||
pub struct ChecksumReader<R> {
|
||||
reader: R,
|
||||
|
@ -3,8 +3,9 @@ use std::io::Write;
|
||||
|
||||
use anyhow::{Error};
|
||||
|
||||
use pbs_tools::borrow::Tied;
|
||||
|
||||
use super::CryptConfig;
|
||||
use crate::tools::borrow::Tied;
|
||||
|
||||
pub struct ChecksumWriter<W> {
|
||||
writer: W,
|
||||
|
@ -190,7 +190,7 @@ impl ChunkStore {
|
||||
pub fn get_chunk_iterator(
|
||||
&self,
|
||||
) -> Result<
|
||||
impl Iterator<Item = (Result<tools::fs::ReadDirEntry, Error>, usize, bool)> + std::iter::FusedIterator,
|
||||
impl Iterator<Item = (Result<pbs_tools::fs::ReadDirEntry, Error>, usize, bool)> + std::iter::FusedIterator,
|
||||
Error
|
||||
> {
|
||||
use nix::dir::Dir;
|
||||
@ -208,7 +208,7 @@ impl ChunkStore {
|
||||
})?;
|
||||
|
||||
let mut done = false;
|
||||
let mut inner: Option<tools::fs::ReadDir> = None;
|
||||
let mut inner: Option<pbs_tools::fs::ReadDir> = None;
|
||||
let mut at = 0;
|
||||
let mut percentage = 0;
|
||||
Ok(std::iter::from_fn(move || {
|
||||
@ -252,7 +252,7 @@ impl ChunkStore {
|
||||
let subdir: &str = &format!("{:04x}", at);
|
||||
percentage = (at * 100) / 0x10000;
|
||||
at += 1;
|
||||
match tools::fs::read_subdir(base_handle.as_raw_fd(), subdir) {
|
||||
match pbs_tools::fs::read_subdir(base_handle.as_raw_fd(), subdir) {
|
||||
Ok(dir) => {
|
||||
inner = Some(dir);
|
||||
// start reading:
|
||||
|
@ -17,10 +17,10 @@ use openssl::pkcs5::pbkdf2_hmac;
|
||||
use openssl::symm::{decrypt_aead, Cipher, Crypter, Mode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::tools::format::{as_fingerprint, bytes_as_fingerprint};
|
||||
|
||||
use proxmox::api::api;
|
||||
|
||||
use pbs_tools::format::{as_fingerprint, bytes_as_fingerprint};
|
||||
|
||||
// openssl::sha::sha256(b"Proxmox Backup Encryption Key Fingerprint")
|
||||
/// This constant is used to compute fingerprints.
|
||||
const FINGERPRINT_INPUT: [u8; 32] = [
|
||||
|
@ -12,6 +12,9 @@ use lazy_static::lazy_static;
|
||||
|
||||
use proxmox::tools::fs::{replace_file, file_read_optional_string, CreateOptions, open_file_locked};
|
||||
|
||||
use pbs_tools::format::HumanByte;
|
||||
use pbs_tools::fs::{lock_dir_noblock, DirLockGuard};
|
||||
|
||||
use super::backup_info::{BackupGroup, BackupDir};
|
||||
use super::chunk_store::ChunkStore;
|
||||
use super::dynamic_index::{DynamicIndexReader, DynamicIndexWriter};
|
||||
@ -22,8 +25,6 @@ use super::{DataBlob, ArchiveType, archive_type};
|
||||
use crate::config::datastore::{self, DataStoreConfig};
|
||||
use crate::task::TaskState;
|
||||
use crate::tools;
|
||||
use crate::tools::format::HumanByte;
|
||||
use crate::tools::fs::{lock_dir_noblock, DirLockGuard};
|
||||
use crate::api2::types::{Authid, GarbageCollectionStatus};
|
||||
use crate::server::UPID;
|
||||
|
||||
@ -110,7 +111,7 @@ impl DataStore {
|
||||
pub fn get_chunk_iterator(
|
||||
&self,
|
||||
) -> Result<
|
||||
impl Iterator<Item = (Result<tools::fs::ReadDirEntry, Error>, usize, bool)>,
|
||||
impl Iterator<Item = (Result<pbs_tools::fs::ReadDirEntry, Error>, usize, bool)>,
|
||||
Error
|
||||
> {
|
||||
self.chunk_store.get_chunk_iterator()
|
||||
@ -215,7 +216,7 @@ impl DataStore {
|
||||
wanted_files.insert(CLIENT_LOG_BLOB_NAME.to_string());
|
||||
manifest.files().iter().for_each(|item| { wanted_files.insert(item.filename.clone()); });
|
||||
|
||||
for item in tools::fs::read_subdir(libc::AT_FDCWD, &full_path)? {
|
||||
for item in pbs_tools::fs::read_subdir(libc::AT_FDCWD, &full_path)? {
|
||||
if let Ok(item) = item {
|
||||
if let Some(file_type) = item.file_type() {
|
||||
if file_type != nix::dir::Type::File { continue; }
|
||||
@ -254,7 +255,7 @@ impl DataStore {
|
||||
|
||||
let full_path = self.group_path(backup_group);
|
||||
|
||||
let _guard = tools::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
|
||||
let _guard = pbs_tools::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
|
||||
|
||||
log::info!("removing backup group {:?}", full_path);
|
||||
|
||||
|
@ -100,7 +100,7 @@ impl From<&KeyConfig> for KeyInfo {
|
||||
fingerprint: key_config
|
||||
.fingerprint
|
||||
.as_ref()
|
||||
.map(|fp| crate::tools::format::as_fingerprint(fp.bytes())),
|
||||
.map(|fp| pbs_tools::format::as_fingerprint(fp.bytes())),
|
||||
hint: key_config.hint.clone(),
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ use std::time::Instant;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
|
||||
use pbs_tools::fs::lock_dir_noblock_shared;
|
||||
|
||||
use crate::{
|
||||
api2::types::*,
|
||||
backup::{
|
||||
@ -25,7 +27,6 @@ use crate::{
|
||||
server::UPID,
|
||||
task::TaskState,
|
||||
task_log,
|
||||
tools::fs::lock_dir_noblock_shared,
|
||||
tools::ParallelHandler,
|
||||
};
|
||||
|
||||
@ -577,4 +578,4 @@ pub fn verify_filter(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user