]> git.proxmox.com Git - proxmox.git/commitdiff
use new proxmox-sys crate
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 19 Nov 2021 09:51:41 +0000 (10:51 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 19 Nov 2021 10:06:35 +0000 (11:06 +0100)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
proxmox-rest-server/Cargo.toml
proxmox-rest-server/src/worker_task.rs

index f0c0c65ee52b84128b33c85e489d7c6eadcabec9..71afbc8ff97699d4a1c97b6d9628d07b6c226242 100644 (file)
@@ -37,6 +37,7 @@ proxmox-http = { version = "0.5.0", features = [ "client" ] }
 proxmox-router = "1.1"
 proxmox-schema = { version = "1", features = [ "api-macro", "upid-api-impl" ] }
 proxmox-time = "1"
+proxmox-sys = "0.1"
 
 # fixme: remove this dependency (pbs_tools::broadcast_future)
 pbs-tools = { path = "../pbs-tools" }
index 242d2de23e76206ece641efcc22d3cd370706860..a83679deee7711bbe4be16c316c542cfd891ace5 100644 (file)
@@ -21,8 +21,8 @@ use proxmox::tools::fs::{create_path, replace_file, atomic_open_or_create_file,
 use proxmox_lang::try_block;
 use proxmox_schema::upid::UPID;
 
-use pbs_tools::task::WorkerTaskContext;
-use pbs_tools::logrotate::{LogRotate, LogRotateFiles};
+use proxmox_sys::worker_task_context::{WorkerTaskContext};
+use proxmox_sys::logrotate::{LogRotate, LogRotateFiles};
 
 use crate::{CommandSocket, FileLogger, FileLogOptions};
 
@@ -209,16 +209,25 @@ pub fn init_worker_tasks(basedir: PathBuf, file_opts: CreateOptions) -> Result<(
 
 /// checks if the Task Archive is bigger that 'size_threshold' bytes, and
 /// rotates it if it is
-pub fn rotate_task_log_archive(size_threshold: u64, compress: bool, max_files: Option<usize>) -> Result<bool, Error> {
+pub fn rotate_task_log_archive(
+    size_threshold: u64,
+    compress: bool,
+    max_files: Option<usize>,
+    options: Option<CreateOptions>,
+) -> Result<bool, Error> {
 
     let setup = worker_task_setup()?;
 
     let _lock = setup.lock_task_list_files(true)?;
 
-    let mut logrotate = LogRotate::new(&setup.task_archive_fn, compress)
-            .ok_or_else(|| format_err!("could not get archive file names"))?;
+    let mut logrotate = LogRotate::new(
+        &setup.task_archive_fn,
+        compress,
+        max_files,
+        options,
+    )?;
 
-    logrotate.rotate(size_threshold, None, max_files)
+    logrotate.rotate(size_threshold)
 }
 
 /// removes all task logs that are older than the oldest task entry in the
@@ -228,8 +237,12 @@ pub fn cleanup_old_tasks(compressed: bool) -> Result<(), Error> {
 
     let _lock = setup.lock_task_list_files(true)?;
 
-    let logrotate = LogRotate::new(&setup.task_archive_fn, compressed)
-            .ok_or_else(|| format_err!("could not get archive file names"))?;
+    let logrotate = LogRotate::new(
+        &setup.task_archive_fn,
+        compressed,
+        None,
+        None,
+    )?;
 
     let mut timestamp = None;
     if let Some(last_file) = logrotate.files().last() {
@@ -649,8 +662,7 @@ impl TaskListInfoIterator {
         let archive = if active_only {
             None
         } else {
-            let logrotate = LogRotate::new(&setup.task_archive_fn, true)
-                .ok_or_else(|| format_err!("could not get archive file names"))?;
+            let logrotate = LogRotate::new(&setup.task_archive_fn, true, None, None)?;
             Some(logrotate.files())
         };