* [pbs-devel] [PATCH proxmox-backup] task archive rotation: better handle non-existing archive
@ 2020-10-02 13:20 Dominik Csapak
2020-10-05 8:04 ` [pbs-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2020-10-02 13:20 UTC (permalink / raw)
To: pbs-devel
if the archive file does not exist yet, we cannot rotate it, but it's not
actually an error, so just return Ok(false) to indicate no rotation took
place
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/server/worker_task.rs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs
index b2e2abd5..409e7b49 100644
--- a/src/server/worker_task.rs
+++ b/src/server/worker_task.rs
@@ -345,7 +345,12 @@ fn lock_task_list_files(exclusive: bool) -> Result<std::fs::File, Error> {
pub fn rotate_task_log_archive(size_threshold: u64, compress: bool, max_files: Option<usize>) -> Result<bool, Error> {
let _lock = lock_task_list_files(true)?;
let path = Path::new(PROXMOX_BACKUP_ARCHIVE_TASK_FN);
- let metadata = path.metadata()?;
+ let metadata = match path.metadata() {
+ Ok(metadata) => metadata,
+ Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(false),
+ Err(err) => bail!("unable to open task archive - {}", err),
+ };
+
if metadata.len() > size_threshold {
let mut logrotate = LogRotate::new(PROXMOX_BACKUP_ARCHIVE_TASK_FN, compress).ok_or_else(|| format_err!("could not get archive file names"))?;
let backup_user = crate::backup::backup_user()?;
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup] task archive rotation: better handle non-existing archive
2020-10-02 13:20 [pbs-devel] [PATCH proxmox-backup] task archive rotation: better handle non-existing archive Dominik Csapak
@ 2020-10-05 8:04 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2020-10-05 8:04 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dominik Csapak
On 02.10.20 15:20, Dominik Csapak wrote:
> if the archive file does not exist yet, we cannot rotate it, but it's not
> actually an error, so just return Ok(false) to indicate no rotation took
> place
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/server/worker_task.rs | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-05 8:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 13:20 [pbs-devel] [PATCH proxmox-backup] task archive rotation: better handle non-existing archive Dominik Csapak
2020-10-05 8:04 ` [pbs-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox