in progress_tracking/src/upload_tracking.rs [89:128]
fn register_new_file(
&mut self,
name: impl Into<Arc<str>>,
n_bytes: u64,
) -> (ProgressUpdate, CompletionTrackerFileId) {
// The file's ID is simply its index in the internal `files` vector.
let file_id = self.files.len() as CompletionTrackerFileId;
// Create a new FileDependency record.
let file_dependency = FileDependency {
name: name.into(),
total_bytes: n_bytes,
completed_bytes: 0,
remaining_xorbs_parts: HashMap::new(),
};
// Insert it into our files vector.
self.files.push(file_dependency);
// We have more to process now.
self.total_bytes += n_bytes;
// Register that the total bytes known has changed, and return the file ID so the caller can register
// dependencies on this file.
(
ProgressUpdate {
item_updates: vec![],
total_bytes: self.total_bytes,
total_bytes_increment: n_bytes,
total_bytes_completed: self.total_bytes_completed,
total_bytes_completion_increment: 0,
total_transfer_bytes: self.total_upload_bytes,
total_transfer_bytes_increment: 0,
total_transfer_bytes_completed: self.total_upload_bytes_completed,
total_transfer_bytes_completion_increment: 0,
..Default::default()
},
file_id,
)
}