Skip to content

Commit 8528b95

Browse files
committed
improve
1 parent be90166 commit 8528b95

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/commands/build/snapshots.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use clap::{Arg, ArgMatches, Command};
88
use console::style;
99
use log::{debug, info, warn};
1010
use objectstore_client::{ClientBuilder, ExpirationPolicy, Usecase};
11-
use sha2::{Digest as _, Sha256};
1211
use secrecy::ExposeSecret as _;
12+
use sha2::{Digest as _, Sha256};
1313
use walkdir::WalkDir;
1414

1515
use crate::api::{Api, CreateSnapshotResponse, ImageMetadata, SnapshotsManifest};
@@ -47,7 +47,7 @@ pub fn make_command(command: Command) -> Command {
4747

4848
struct ImageInfo {
4949
path: std::path::PathBuf,
50-
relative_path: String,
50+
relative_path: std::path::PathBuf,
5151
width: u32,
5252
height: u32,
5353
}
@@ -156,11 +156,7 @@ fn collect_image_info(dir: &Path, path: &Path) -> Option<ImageInfo> {
156156
return None;
157157
}
158158
};
159-
let relative = path
160-
.strip_prefix(dir)
161-
.unwrap_or(path)
162-
.to_string_lossy()
163-
.to_string();
159+
let relative = path.strip_prefix(dir).unwrap_or(path).to_path_buf();
164160

165161
Some(ImageInfo {
166162
path: path.to_path_buf(),
@@ -235,7 +231,7 @@ fn upload_images(
235231
.with_context(|| format!("Failed to read image: {}", image.path.display()))?;
236232
let hash = compute_sha256_hash(&contents);
237233

238-
info!("Queueing {} as {hash}", image.relative_path);
234+
info!("Queueing {} as {hash}", image.relative_path.display());
239235

240236
many_builder = many_builder.push(
241237
session
@@ -244,7 +240,8 @@ fn upload_images(
244240
.expiration_policy(expiration),
245241
);
246242

247-
let image_file_name = Path::new(&image.relative_path)
243+
let image_file_name = image
244+
.relative_path
248245
.file_name()
249246
.unwrap_or_default()
250247
.to_string_lossy()

0 commit comments

Comments
 (0)