From 7a44eb6350a721b23fbc039d097ef05a0c031865 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 30 Jan 2023 21:08:44 +0800 Subject: [PATCH] Calculate checksum only at real publish Signed-off-by: hi-rustin --- src/cargo/ops/registry.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 091c26b6070..0584a771457 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -202,21 +202,20 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> { )? .unwrap(); - let hash = cargo_util::Sha256::new() - .update_file(tarball.file())? - .finish_hex(); - let mutation = auth::Mutation::Publish { - name: pkg.name().as_str(), - vers: &ver, - cksum: &hash, - }; - if !opts.dry_run { + let hash = cargo_util::Sha256::new() + .update_file(tarball.file())? + .finish_hex(); + let mutation = Some(auth::Mutation::Publish { + name: pkg.name().as_str(), + vers: &ver, + cksum: &hash, + }); registry.set_token(Some(auth::auth_token( &opts.config, ®_ids.original, None, - Some(mutation), + mutation, )?)); }