From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C554B1FF161 for ; Tue, 13 Aug 2024 10:44:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A66773DE1B; Tue, 13 Aug 2024 10:44:50 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Tue, 13 Aug 2024 10:44:14 +0200 Message-Id: <20240813084416.177460-9-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240813084416.177460-1-m.sandoval@proxmox.com> References: <20240813084416.177460-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.118 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH backup 09/11] restore-daemon: remove lazy_static dependency X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Signed-off-by: Maximiliano Sandoval --- proxmox-restore-daemon/Cargo.toml | 2 +- proxmox-restore-daemon/src/main.rs | 12 +++---- .../src/proxmox_restore_daemon/disk.rs | 32 +++++++++---------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/proxmox-restore-daemon/Cargo.toml b/proxmox-restore-daemon/Cargo.toml index 161b371d..beb455e5 100644 --- a/proxmox-restore-daemon/Cargo.toml +++ b/proxmox-restore-daemon/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" authors.workspace = true edition.workspace = true description = "Proxmox Restore Daemon" +rust-version.workspace = true [dependencies] anyhow.workspace = true @@ -12,7 +13,6 @@ env_logger.workspace = true futures.workspace = true http.workspace = true hyper.workspace = true -lazy_static.workspace = true libc.workspace = true log.workspace = true nix.workspace = true diff --git a/proxmox-restore-daemon/src/main.rs b/proxmox-restore-daemon/src/main.rs index f94b6c67..0131d771 100644 --- a/proxmox-restore-daemon/src/main.rs +++ b/proxmox-restore-daemon/src/main.rs @@ -6,10 +6,9 @@ use std::os::unix::{ net, }; use std::path::Path; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, LazyLock, Mutex}; use anyhow::{bail, format_err, Error}; -use lazy_static::lazy_static; use log::{error, info}; use tokio::sync::mpsc; use tokio_stream::wrappers::ReceiverStream; @@ -29,12 +28,9 @@ pub const MAX_PENDING: usize = 32; /// Will be present in base initramfs pub const VM_DETECT_FILE: &str = "/restore-vm-marker"; -lazy_static! { - /// The current disks state. Use for accessing data on the attached snapshots. - pub static ref DISK_STATE: Arc> = { - Arc::new(Mutex::new(DiskState::scan().unwrap())) - }; -} +/// The current disks state. Use for accessing data on the attached snapshots. +pub static DISK_STATE: LazyLock>> = + LazyLock::new(|| Arc::new(Mutex::new(DiskState::scan().unwrap()))); fn init_disk_state() { info!("scanning all disks..."); diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs index 20ddfc6b..f60dbbfa 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs @@ -4,9 +4,9 @@ use std::fs::{create_dir_all, File}; use std::io::{BufRead, BufReader}; use std::path::{Component, Path, PathBuf}; use std::process::Command; +use std::sync::LazyLock; use anyhow::{bail, format_err, Error}; -use lazy_static::lazy_static; use log::{info, warn}; use proxmox_schema::const_regex; @@ -21,27 +21,25 @@ const_regex! { ZPOOL_IMPORT_DISK_REGEX = r"^\t {2,4}(vd[a-z]+(?:\d+)?)\s+ONLINE$"; } -lazy_static! { - static ref FS_OPT_MAP: HashMap<&'static str, &'static str> = { - let mut m = HashMap::new(); +static FS_OPT_MAP: LazyLock> = LazyLock::new(|| { + let mut m = HashMap::new(); - // otherwise ext complains about mounting read-only - m.insert("ext2", "noload"); - m.insert("ext3", "noload"); - m.insert("ext4", "noload"); + // otherwise ext complains about mounting read-only + m.insert("ext2", "noload"); + m.insert("ext3", "noload"); + m.insert("ext4", "noload"); - m.insert("xfs", "norecovery"); + m.insert("xfs", "norecovery"); - // ufs2 is used as default since FreeBSD 5.0 released in 2003, so let's assume that - // whatever the user is trying to restore is not using anything older... - m.insert("ufs", "ufstype=ufs2"); + // ufs2 is used as default since FreeBSD 5.0 released in 2003, so let's assume that + // whatever the user is trying to restore is not using anything older... + m.insert("ufs", "ufstype=ufs2"); - m.insert("ntfs", "utf8"); - m.insert("ntfs3", "iocharset=utf8"); + m.insert("ntfs", "utf8"); + m.insert("ntfs3", "iocharset=utf8"); - m - }; -} + m +}); pub enum ResolveResult { Path(PathBuf), -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel