diff --git a/proxmox-log/src/file_logger.rs b/proxmox-log/src/file_logger.rs index 1e67b450..39d16857 100644 --- a/proxmox-log/src/file_logger.rs +++ b/proxmox-log/src/file_logger.rs @@ -93,8 +93,7 @@ impl FileLogger { flags |= OFlag::O_EXCL; } - let file = - atomic_open_or_create_file(&file_name, flags, &[], options.file_opts.clone(), false)?; + let file = atomic_open_or_create_file(&file_name, flags, &[], options.file_opts, false)?; Ok(file) } diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index 24e2676e..9351bbee 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -136,7 +136,6 @@ impl WorkerTaskSetup { fn lock_task_list_files(&self, exclusive: bool) -> Result { let options = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o660)); let timeout = std::time::Duration::new(15, 0); @@ -163,7 +162,6 @@ impl WorkerTaskSetup { let mut path = self.log_directory(upid); let dir_opts = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o755)); create_path(&path, None, Some(dir_opts))?; @@ -222,7 +220,6 @@ impl WorkerTaskSetup { let options = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o660)); replace_file(&self.active_tasks_fn, active_raw.as_bytes(), options, false)?; @@ -237,7 +234,6 @@ impl WorkerTaskSetup { if !finish_list.is_empty() { let options = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o660)); let mut writer = atomic_open_or_create_file( @@ -268,10 +264,9 @@ impl WorkerTaskSetup { try_block!({ let dir_opts = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o755)); - create_path(&self.taskdir, Some(dir_opts.clone()), Some(dir_opts))?; + create_path(&self.taskdir, Some(dir_opts), Some(dir_opts))?; // fixme:??? create_path(pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, None, Some(opts))?; Ok(()) }) @@ -901,7 +896,7 @@ impl WorkerTask { exclusive: true, prefix_time: true, read: true, - file_opts: setup.file_opts.clone(), + file_opts: setup.file_opts, ..Default::default() }; let logger = FileLogger::new(path, logger_options)?; diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs index 9dd85a16..29d46ed5 100644 --- a/proxmox-rrd/src/cache.rs +++ b/proxmox-rrd/src/cache.rs @@ -66,12 +66,8 @@ impl Cache { let file_options = file_options.unwrap_or_default(); let dir_options = dir_options.unwrap_or_default(); - create_path( - &basedir, - Some(dir_options.clone()), - Some(dir_options.clone()), - ) - .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?; + create_path(&basedir, Some(dir_options), Some(dir_options)) + .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?; let config = Arc::new(CacheConfig { basedir, diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs index c196b342..fe48f23b 100644 --- a/proxmox-rrd/src/cache/journal.rs +++ b/proxmox-rrd/src/cache/journal.rs @@ -112,13 +112,8 @@ impl JournalState { journal_path.push(RRD_JOURNAL_NAME); let flags = OFlag::O_CLOEXEC | OFlag::O_RDONLY; - let journal = atomic_open_or_create_file( - &journal_path, - flags, - &[], - self.config.file_options.clone(), - false, - )?; + let journal = + atomic_open_or_create_file(&journal_path, flags, &[], self.config.file_options, false)?; Ok(BufReader::new(journal)) } @@ -127,13 +122,8 @@ impl JournalState { journal_path.push(RRD_JOURNAL_NAME); let flags = OFlag::O_CLOEXEC | OFlag::O_WRONLY | OFlag::O_APPEND; - let journal = atomic_open_or_create_file( - &journal_path, - flags, - &[], - config.file_options.clone(), - false, - )?; + let journal = + atomic_open_or_create_file(&journal_path, flags, &[], config.file_options, false)?; Ok(journal) } diff --git a/proxmox-rrd/src/cache/rrd_map.rs b/proxmox-rrd/src/cache/rrd_map.rs index 0ef61cfa..27ea8e6e 100644 --- a/proxmox-rrd/src/cache/rrd_map.rs +++ b/proxmox-rrd/src/cache/rrd_map.rs @@ -51,8 +51,8 @@ impl RRDMap { None => { create_path( path.parent().unwrap(), - Some(self.config.dir_options.clone()), - Some(self.config.dir_options.clone()), + Some(self.config.dir_options), + Some(self.config.dir_options), )?; (self.create_rrd_cb)(dst) @@ -82,7 +82,7 @@ impl RRDMap { if let Some(rrd) = self.map.get(rel_path) { let mut path = self.config.basedir.clone(); path.push(rel_path); - rrd.save(&path, self.config.file_options.clone(), true) + rrd.save(&path, self.config.file_options, true) } else { bail!("rrd file {} not loaded", rel_path); } diff --git a/proxmox-shared-cache/src/lib.rs b/proxmox-shared-cache/src/lib.rs index d0b2148a..65abc1ac 100644 --- a/proxmox-shared-cache/src/lib.rs +++ b/proxmox-shared-cache/src/lib.rs @@ -127,7 +127,7 @@ impl SharedCache { proxmox_sys::fs::replace_file( &self.path, new_content.as_bytes(), - self.create_options.clone(), + self.create_options, true, )?; @@ -137,7 +137,7 @@ impl SharedCache { /// Removes all items from the cache. pub fn delete(&self, lock_timeout: Duration) -> Result<(), Error> { let _lock = self.lock(lock_timeout)?; - proxmox_sys::fs::replace_file(&self.path, &[], self.create_options.clone(), true)?; + proxmox_sys::fs::replace_file(&self.path, &[], self.create_options, true)?; Ok(()) } @@ -145,12 +145,7 @@ impl SharedCache { fn lock(&self, lock_timeout: Duration) -> Result { let mut lockfile_path = self.path.clone(); lockfile_path.set_extension("lock"); - proxmox_sys::fs::open_file_locked( - lockfile_path, - lock_timeout, - true, - self.create_options.clone(), - ) + proxmox_sys::fs::open_file_locked(lockfile_path, lock_timeout, true, self.create_options) } } @@ -178,12 +173,7 @@ mod tests { .group(nix::unistd::Gid::effective()) .perm(nix::sys::stat::Mode::from_bits_truncate(0o700)); - proxmox_sys::fs::create_path( - &path, - Some(dir_options.clone()), - Some(dir_options.clone()), - ) - .unwrap(); + proxmox_sys::fs::create_path(&path, Some(dir_options), Some(dir_options)).unwrap(); let cache = SharedCache::new(path.join("somekey"), options, keep_old).unwrap(); Self { diff --git a/proxmox-sys/src/logrotate.rs b/proxmox-sys/src/logrotate.rs index 704a18ce..cb96974a 100644 --- a/proxmox-sys/src/logrotate.rs +++ b/proxmox-sys/src/logrotate.rs @@ -64,7 +64,7 @@ impl LogRotate { options: &CreateOptions, ) -> Result<(), Error> { let mut source = File::open(source_path)?; - let (fd, tmp_path) = make_tmp_file(target_path, options.clone())?; + let (fd, tmp_path) = make_tmp_file(target_path, *options)?; let target = unsafe { File::from_raw_fd(fd.into_raw_fd()) }; let mut encoder = match zstd::stream::write::Encoder::new(target, 0) { Ok(encoder) => encoder,