Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
FM-363: Remove 'parts'
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Dec 12, 2023
1 parent 5d00e7a commit a2e6f10
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions fendermint/vm/snapshot/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ impl SnapshotClient {
} else {
match tempfile::tempdir_in(&self.download_dir) {
Ok(dir) => {
// Create a `parts` sub-directory for the chunks.
if let Err(e) = std::fs::create_dir(dir.path().join("parts")) {
return abort(SnapshotError::from(e));
};

// Save the manifest into the temp directory;
// that way we can always see on the file system what's happening.
let json = match serde_json::to_string_pretty(&manifest)
Expand All @@ -98,17 +93,23 @@ impl SnapshotClient {
Ok(json) => json,
Err(e) => return abort(SnapshotError::from(e)),
};
if let Err(e) = std::fs::write(dir.path().join(MANIFEST_FILE_NAME), json) {
return abort(SnapshotError::from(e));
}

let download_path = dir.path().into();
let download_path: PathBuf = dir.path().into();
let download = SnapshotDownload {
manifest,
download_dir: Arc::new(dir),
next_index: TVar::new(0),
};

// Create a `parts` sub-directory for the chunks.
if let Err(e) = std::fs::create_dir(download.parts_dir()) {
return abort(SnapshotError::from(e));
};

if let Err(e) = std::fs::write(download_path.join(MANIFEST_FILE_NAME), json) {
return abort(SnapshotError::from(e));
}

self.state.current_download.write(Some(download))?;

Ok(download_path)
Expand Down

0 comments on commit a2e6f10

Please sign in to comment.