From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B46FA77FB8 for ; Thu, 29 Apr 2021 13:00:23 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AAD121AE2F for ; Thu, 29 Apr 2021 13:00:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3A84C1ADFF for ; Thu, 29 Apr 2021 13:00:22 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D5EEE464C9 for ; Thu, 29 Apr 2021 13:00:21 +0200 (CEST) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Thu, 29 Apr 2021 13:00:14 +0200 Message-Id: <20210429110016.1467670-3-h.laimer@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210429110016.1467670-1-h.laimer@proxmox.com> References: <20210429110016.1467670-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [index.rs] Subject: [pbs-devel] [PATCH v5 proxmox-backup 2/4] add ctime and size function to IndexFile trait X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2021 11:00:23 -0000 Signed-off-by: Hannes Laimer --- needed for next patch in order to avoid duplicating code for fixed and dynamic indexes src/backup/dynamic_index.rs | 8 ++++++++ src/backup/fixed_index.rs | 8 ++++++++ src/backup/index.rs | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/backup/dynamic_index.rs b/src/backup/dynamic_index.rs index 1619d8db..8321b295 100644 --- a/src/backup/dynamic_index.rs +++ b/src/backup/dynamic_index.rs @@ -233,6 +233,14 @@ impl IndexFile for DynamicIndexReader { }) } + fn index_ctime(&self) -> i64 { + self.ctime + } + + fn index_size(&self) -> usize { + self.size as usize + } + fn chunk_from_offset(&self, offset: u64) -> Option<(usize, u64)> { let end_idx = self.index.len() - 1; let end = self.chunk_end(end_idx); diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index ceb6fe29..ebf64456 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -193,6 +193,14 @@ impl IndexFile for FixedIndexReader { }) } + fn index_ctime(&self) -> i64 { + self.ctime + } + + fn index_size(&self) -> usize { + self.size as usize + } + fn compute_csum(&self) -> ([u8; 32], u64) { let mut csum = openssl::sha::Sha256::new(); let mut chunk_end = 0; diff --git a/src/backup/index.rs b/src/backup/index.rs index c6bab56e..69788f80 100644 --- a/src/backup/index.rs +++ b/src/backup/index.rs @@ -22,6 +22,8 @@ pub trait IndexFile { fn index_digest(&self, pos: usize) -> Option<&[u8; 32]>; fn index_bytes(&self) -> u64; fn chunk_info(&self, pos: usize) -> Option; + fn index_ctime(&self) -> i64; + fn index_size(&self) -> usize; /// Get the chunk index and the relative offset within it for a byte offset fn chunk_from_offset(&self, offset: u64) -> Option<(usize, u64)>; -- 2.20.1