Skip to content

Commit 7a44eb6

Browse files
committed
Calculate checksum only at real publish
Signed-off-by: hi-rustin <[email protected]>
1 parent e5aea70 commit 7a44eb6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/cargo/ops/registry.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,20 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
202202
)?
203203
.unwrap();
204204

205-
let hash = cargo_util::Sha256::new()
206-
.update_file(tarball.file())?
207-
.finish_hex();
208-
let mutation = auth::Mutation::Publish {
209-
name: pkg.name().as_str(),
210-
vers: &ver,
211-
cksum: &hash,
212-
};
213-
214205
if !opts.dry_run {
206+
let hash = cargo_util::Sha256::new()
207+
.update_file(tarball.file())?
208+
.finish_hex();
209+
let mutation = Some(auth::Mutation::Publish {
210+
name: pkg.name().as_str(),
211+
vers: &ver,
212+
cksum: &hash,
213+
});
215214
registry.set_token(Some(auth::auth_token(
216215
&opts.config,
217216
&reg_ids.original,
218217
None,
219-
Some(mutation),
218+
mutation,
220219
)?));
221220
}
222221

0 commit comments

Comments
 (0)