From 86f6f7411438ce9ca89d0d7a47beeddc7e3da7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 21 Jul 2020 15:03:33 +0200 Subject: [PATCH] fix #2860: skip in-progress snapshots when syncing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit they don't have a final manifest yet and are not done, so they can't be synced either. Signed-off-by: Fabian Grünbichler --- src/client/pull.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client/pull.rs b/src/client/pull.rs index 5cf0dd1f..bbe01969 100644 --- a/src/client/pull.rs +++ b/src/client/pull.rs @@ -6,7 +6,6 @@ use std::convert::TryFrom; use std::sync::Arc; use std::collections::HashMap; use std::io::{Seek, SeekFrom}; -use chrono::{Utc, TimeZone}; use crate::server::{WorkerTask}; use crate::backup::*; @@ -302,7 +301,16 @@ pub async fn pull_group( let mut remote_snapshots = std::collections::HashSet::new(); for item in list { - let backup_time = Utc.timestamp(item.backup_time, 0); + let snapshot = BackupDir::new(item.backup_type, item.backup_id, item.backup_time); + + // in-progress backups can't be synced + if let None = item.size { + worker.log(format!("skipping snapshot {} - in-progress backup", snapshot)); + continue; + } + + let backup_time = snapshot.backup_time(); + remote_snapshots.insert(backup_time); if let Some(last_sync_time) = last_sync { @@ -319,14 +327,12 @@ pub async fn pull_group( new_client, None, src_repo.store(), - &item.backup_type, - &item.backup_id, + snapshot.group().backup_type(), + snapshot.group().backup_id(), backup_time, true, ).await?; - let snapshot = BackupDir::new(item.backup_type, item.backup_id, item.backup_time); - pull_snapshot_from(worker, reader, tgt_store.clone(), &snapshot).await?; }