Skip to content

Commit

Permalink
Calculate checksum only at real publish
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Jan 30, 2023
1 parent e5aea70 commit 7a44eb6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
&reg_ids.original,
None,
Some(mutation),
mutation,
)?));
}

Expand Down

0 comments on commit 7a44eb6

Please sign in to comment.