Page MenuHomePhabricator

D4442.diff
No OneTemporary

D4442.diff

diff --git a/services/commtest/tests/backup/pull_backup.rs b/services/commtest/tests/backup/pull_backup.rs
--- a/services/commtest/tests/backup/pull_backup.rs
+++ b/services/commtest/tests/backup/pull_backup.rs
@@ -3,8 +3,8 @@
#[path = "../lib/tools.rs"]
mod tools;
-use tonic::Request;
use std::io::{Error as IOError, ErrorKind};
+use tonic::Request;
use crate::backup_utils::{
proto::pull_backup_response::Data, proto::pull_backup_response::Data::*,
@@ -55,6 +55,12 @@
Some(LogId(id)) => log_id = Some(id),
None => {}
};
+ let attachment_holders =
+ response.attachment_holders.unwrap_or("".to_string());
+ let mut holders_split: Vec<&str> = Vec::new();
+ if !attachment_holders.is_empty() {
+ holders_split = attachment_holders.split(ATTACHMENT_DELIMITER).collect();
+ }
match response_data {
Some(CompactionChunk(chunk)) => {
assert_eq!(
@@ -63,20 +69,38 @@
"invalid state, expected compaction, got {:?}",
state
);
- current_id = backup_id.ok_or(IOError::new(ErrorKind::Other, "backup id expected but not received"))?;
+ current_id = backup_id.ok_or(IOError::new(
+ ErrorKind::Other,
+ "backup id expected but not received",
+ ))?;
+ result.backup_item.chunks_sizes.push(chunk.len());
println!(
- "compaction (id {}), pushing chunk (size: {})",
+ "compaction (id {}), pushing chunk (size: {}), attachments: {}",
current_id,
- chunk.len()
+ chunk.len(),
+ holders_split.len()
);
- result.backup_item.chunks_sizes.push(chunk.len())
+ if !holders_split.is_empty() {
+ for holder in holders_split {
+ if holder.is_empty() {
+ continue;
+ }
+ result
+ .backup_item
+ .attachments_holders
+ .push(holder.to_string());
+ }
+ }
}
Some(LogChunk(chunk)) => {
if state == State::Compaction {
state = State::Log;
}
assert_eq!(state, State::Log, "invalid state, expected compaction");
- let log_id = log_id.ok_or(IOError::new(ErrorKind::Other, "log id expected but not received"))?;
+ let log_id = log_id.ok_or(IOError::new(
+ ErrorKind::Other,
+ "log id expected but not received",
+ ))?;
if log_id != current_id {
result.log_items.push(Item::new(
log_id.clone(),
@@ -89,33 +113,21 @@
result.log_items[log_items_size]
.chunks_sizes
.push(chunk.len());
-
- println!("log (id {}) chunk size {}", current_id, chunk.len());
- }
- Some(AttachmentHolders(holders)) => {
- let holders_split: Vec<&str> =
- holders.split(ATTACHMENT_DELIMITER).collect();
- if state == State::Compaction {
- println!("attachments for the backup: {}", holders);
- for holder in holders_split {
- if holder.len() == 0 {
- continue;
- }
- result
- .backup_item
- .attachments_holders
- .push(holder.to_string());
- }
- } else if state == State::Log {
- println!("attachments for the log: {}", holders);
+ println!(
+ "log (id {}) chunk size {}, attachments: {}",
+ current_id,
+ chunk.len(),
+ holders_split.len()
+ );
+ if !holders_split.is_empty() {
+ let log_items_size = result.log_items.len() - 1;
for holder in holders_split {
- if holder.len() == 0 {
+ if holder.is_empty() {
continue;
}
- let log_items_size = result.log_items.len() - 1;
result.log_items[log_items_size]
.attachments_holders
- .push(holder.to_string())
+ .push(holder.to_string());
}
}
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 4, 7:07 PM (11 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2614656
Default Alt Text
D4442.diff (3 KB)

Event Timeline