mirror of
https://git.proxmox.com/git/proxmox
synced 2025-07-09 19:57:39 +00:00
tree-wide: remove clone calls on types that are Copy
this resolves a clippy lint that checks that `clone()` isn't called on `Copy` types as that is unnecessary [1]. [1]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
This commit is contained in:
parent
2c07729ff3
commit
d980c2229b
@ -93,8 +93,7 @@ impl FileLogger {
|
|||||||
flags |= OFlag::O_EXCL;
|
flags |= OFlag::O_EXCL;
|
||||||
}
|
}
|
||||||
|
|
||||||
let file =
|
let file = atomic_open_or_create_file(&file_name, flags, &[], options.file_opts, false)?;
|
||||||
atomic_open_or_create_file(&file_name, flags, &[], options.file_opts.clone(), false)?;
|
|
||||||
|
|
||||||
Ok(file)
|
Ok(file)
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,6 @@ impl WorkerTaskSetup {
|
|||||||
fn lock_task_list_files(&self, exclusive: bool) -> Result<TaskListLockGuard, Error> {
|
fn lock_task_list_files(&self, exclusive: bool) -> Result<TaskListLockGuard, Error> {
|
||||||
let options = self
|
let options = self
|
||||||
.file_opts
|
.file_opts
|
||||||
.clone()
|
|
||||||
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
|
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
|
||||||
|
|
||||||
let timeout = std::time::Duration::new(15, 0);
|
let timeout = std::time::Duration::new(15, 0);
|
||||||
@ -163,7 +162,6 @@ impl WorkerTaskSetup {
|
|||||||
let mut path = self.log_directory(upid);
|
let mut path = self.log_directory(upid);
|
||||||
let dir_opts = self
|
let dir_opts = self
|
||||||
.file_opts
|
.file_opts
|
||||||
.clone()
|
|
||||||
.perm(nix::sys::stat::Mode::from_bits_truncate(0o755));
|
.perm(nix::sys::stat::Mode::from_bits_truncate(0o755));
|
||||||
|
|
||||||
create_path(&path, None, Some(dir_opts))?;
|
create_path(&path, None, Some(dir_opts))?;
|
||||||
@ -222,7 +220,6 @@ impl WorkerTaskSetup {
|
|||||||
|
|
||||||
let options = self
|
let options = self
|
||||||
.file_opts
|
.file_opts
|
||||||
.clone()
|
|
||||||
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
|
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
|
||||||
|
|
||||||
replace_file(&self.active_tasks_fn, active_raw.as_bytes(), options, false)?;
|
replace_file(&self.active_tasks_fn, active_raw.as_bytes(), options, false)?;
|
||||||
@ -237,7 +234,6 @@ impl WorkerTaskSetup {
|
|||||||
if !finish_list.is_empty() {
|
if !finish_list.is_empty() {
|
||||||
let options = self
|
let options = self
|
||||||
.file_opts
|
.file_opts
|
||||||
.clone()
|
|
||||||
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
|
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
|
||||||
|
|
||||||
let mut writer = atomic_open_or_create_file(
|
let mut writer = atomic_open_or_create_file(
|
||||||
@ -268,10 +264,9 @@ impl WorkerTaskSetup {
|
|||||||
try_block!({
|
try_block!({
|
||||||
let dir_opts = self
|
let dir_opts = self
|
||||||
.file_opts
|
.file_opts
|
||||||
.clone()
|
|
||||||
.perm(nix::sys::stat::Mode::from_bits_truncate(0o755));
|
.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))?;
|
// fixme:??? create_path(pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, None, Some(opts))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -901,7 +896,7 @@ impl WorkerTask {
|
|||||||
exclusive: true,
|
exclusive: true,
|
||||||
prefix_time: true,
|
prefix_time: true,
|
||||||
read: true,
|
read: true,
|
||||||
file_opts: setup.file_opts.clone(),
|
file_opts: setup.file_opts,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let logger = FileLogger::new(path, logger_options)?;
|
let logger = FileLogger::new(path, logger_options)?;
|
||||||
|
@ -66,12 +66,8 @@ impl Cache {
|
|||||||
let file_options = file_options.unwrap_or_default();
|
let file_options = file_options.unwrap_or_default();
|
||||||
let dir_options = dir_options.unwrap_or_default();
|
let dir_options = dir_options.unwrap_or_default();
|
||||||
|
|
||||||
create_path(
|
create_path(&basedir, Some(dir_options), Some(dir_options))
|
||||||
&basedir,
|
.map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?;
|
||||||
Some(dir_options.clone()),
|
|
||||||
Some(dir_options.clone()),
|
|
||||||
)
|
|
||||||
.map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?;
|
|
||||||
|
|
||||||
let config = Arc::new(CacheConfig {
|
let config = Arc::new(CacheConfig {
|
||||||
basedir,
|
basedir,
|
||||||
|
18
proxmox-rrd/src/cache/journal.rs
vendored
18
proxmox-rrd/src/cache/journal.rs
vendored
@ -112,13 +112,8 @@ impl JournalState {
|
|||||||
journal_path.push(RRD_JOURNAL_NAME);
|
journal_path.push(RRD_JOURNAL_NAME);
|
||||||
|
|
||||||
let flags = OFlag::O_CLOEXEC | OFlag::O_RDONLY;
|
let flags = OFlag::O_CLOEXEC | OFlag::O_RDONLY;
|
||||||
let journal = atomic_open_or_create_file(
|
let journal =
|
||||||
&journal_path,
|
atomic_open_or_create_file(&journal_path, flags, &[], self.config.file_options, false)?;
|
||||||
flags,
|
|
||||||
&[],
|
|
||||||
self.config.file_options.clone(),
|
|
||||||
false,
|
|
||||||
)?;
|
|
||||||
Ok(BufReader::new(journal))
|
Ok(BufReader::new(journal))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,13 +122,8 @@ impl JournalState {
|
|||||||
journal_path.push(RRD_JOURNAL_NAME);
|
journal_path.push(RRD_JOURNAL_NAME);
|
||||||
|
|
||||||
let flags = OFlag::O_CLOEXEC | OFlag::O_WRONLY | OFlag::O_APPEND;
|
let flags = OFlag::O_CLOEXEC | OFlag::O_WRONLY | OFlag::O_APPEND;
|
||||||
let journal = atomic_open_or_create_file(
|
let journal =
|
||||||
&journal_path,
|
atomic_open_or_create_file(&journal_path, flags, &[], config.file_options, false)?;
|
||||||
flags,
|
|
||||||
&[],
|
|
||||||
config.file_options.clone(),
|
|
||||||
false,
|
|
||||||
)?;
|
|
||||||
Ok(journal)
|
Ok(journal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
proxmox-rrd/src/cache/rrd_map.rs
vendored
6
proxmox-rrd/src/cache/rrd_map.rs
vendored
@ -51,8 +51,8 @@ impl RRDMap {
|
|||||||
None => {
|
None => {
|
||||||
create_path(
|
create_path(
|
||||||
path.parent().unwrap(),
|
path.parent().unwrap(),
|
||||||
Some(self.config.dir_options.clone()),
|
Some(self.config.dir_options),
|
||||||
Some(self.config.dir_options.clone()),
|
Some(self.config.dir_options),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
(self.create_rrd_cb)(dst)
|
(self.create_rrd_cb)(dst)
|
||||||
@ -82,7 +82,7 @@ impl RRDMap {
|
|||||||
if let Some(rrd) = self.map.get(rel_path) {
|
if let Some(rrd) = self.map.get(rel_path) {
|
||||||
let mut path = self.config.basedir.clone();
|
let mut path = self.config.basedir.clone();
|
||||||
path.push(rel_path);
|
path.push(rel_path);
|
||||||
rrd.save(&path, self.config.file_options.clone(), true)
|
rrd.save(&path, self.config.file_options, true)
|
||||||
} else {
|
} else {
|
||||||
bail!("rrd file {} not loaded", rel_path);
|
bail!("rrd file {} not loaded", rel_path);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ impl SharedCache {
|
|||||||
proxmox_sys::fs::replace_file(
|
proxmox_sys::fs::replace_file(
|
||||||
&self.path,
|
&self.path,
|
||||||
new_content.as_bytes(),
|
new_content.as_bytes(),
|
||||||
self.create_options.clone(),
|
self.create_options,
|
||||||
true,
|
true,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ impl SharedCache {
|
|||||||
/// Removes all items from the cache.
|
/// Removes all items from the cache.
|
||||||
pub fn delete(&self, lock_timeout: Duration) -> Result<(), Error> {
|
pub fn delete(&self, lock_timeout: Duration) -> Result<(), Error> {
|
||||||
let _lock = self.lock(lock_timeout)?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -145,12 +145,7 @@ impl SharedCache {
|
|||||||
fn lock(&self, lock_timeout: Duration) -> Result<File, Error> {
|
fn lock(&self, lock_timeout: Duration) -> Result<File, Error> {
|
||||||
let mut lockfile_path = self.path.clone();
|
let mut lockfile_path = self.path.clone();
|
||||||
lockfile_path.set_extension("lock");
|
lockfile_path.set_extension("lock");
|
||||||
proxmox_sys::fs::open_file_locked(
|
proxmox_sys::fs::open_file_locked(lockfile_path, lock_timeout, true, self.create_options)
|
||||||
lockfile_path,
|
|
||||||
lock_timeout,
|
|
||||||
true,
|
|
||||||
self.create_options.clone(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,12 +173,7 @@ mod tests {
|
|||||||
.group(nix::unistd::Gid::effective())
|
.group(nix::unistd::Gid::effective())
|
||||||
.perm(nix::sys::stat::Mode::from_bits_truncate(0o700));
|
.perm(nix::sys::stat::Mode::from_bits_truncate(0o700));
|
||||||
|
|
||||||
proxmox_sys::fs::create_path(
|
proxmox_sys::fs::create_path(&path, Some(dir_options), Some(dir_options)).unwrap();
|
||||||
&path,
|
|
||||||
Some(dir_options.clone()),
|
|
||||||
Some(dir_options.clone()),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let cache = SharedCache::new(path.join("somekey"), options, keep_old).unwrap();
|
let cache = SharedCache::new(path.join("somekey"), options, keep_old).unwrap();
|
||||||
Self {
|
Self {
|
||||||
|
@ -64,7 +64,7 @@ impl LogRotate {
|
|||||||
options: &CreateOptions,
|
options: &CreateOptions,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let mut source = File::open(source_path)?;
|
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 target = unsafe { File::from_raw_fd(fd.into_raw_fd()) };
|
||||||
let mut encoder = match zstd::stream::write::Encoder::new(target, 0) {
|
let mut encoder = match zstd::stream::write::Encoder::new(target, 0) {
|
||||||
Ok(encoder) => encoder,
|
Ok(encoder) => encoder,
|
||||||
|
Loading…
Reference in New Issue
Block a user