Skip to content

Commit 8fee50a

Browse files
committed
refactor(vendor): name variables better
1 parent d760d6e commit 8fee50a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/cargo/ops/vendor.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ fn sync(
111111
opts: &VendorOptions<'_>,
112112
) -> CargoResult<VendorConfig> {
113113
let dry_run = false;
114-
let canonical_destination = try_canonicalize(opts.destination);
115-
let canonical_destination = canonical_destination.as_deref().unwrap_or(opts.destination);
116-
let dest_dir_already_exists = canonical_destination.exists();
114+
let vendor_dir = try_canonicalize(opts.destination);
115+
let vendor_dir = vendor_dir.as_deref().unwrap_or(opts.destination);
116+
let vendor_dir_already_exists = vendor_dir.exists();
117117

118-
paths::create_dir_all(&canonical_destination)?;
118+
paths::create_dir_all(&vendor_dir)?;
119119
let mut to_remove = HashSet::new();
120120
if !opts.no_delete {
121-
for entry in canonical_destination.read_dir()? {
121+
for entry in vendor_dir.read_dir()? {
122122
let entry = entry?;
123123
if !entry
124124
.file_name()
@@ -247,7 +247,7 @@ fn sync(
247247
};
248248

249249
sources.insert(id.source_id());
250-
let dst = canonical_destination.join(&dst_name);
250+
let dst = vendor_dir.join(&dst_name);
251251
to_remove.remove(&dst);
252252
let cksum = dst.join(".cargo-checksum.json");
253253
// Registries are the only immutable sources,
@@ -265,14 +265,14 @@ fn sync(
265265
let _ = fs::remove_dir_all(&dst);
266266
let pathsource = PathSource::new(src, id.source_id(), gctx);
267267
let paths = pathsource.list_files(pkg)?;
268-
let mut map = BTreeMap::new();
269-
cp_sources(pkg, src, &paths, &dst, &mut map, &mut tmp_buf, gctx)
268+
let mut file_cksums = BTreeMap::new();
269+
cp_sources(pkg, src, &paths, &dst, &mut file_cksums, &mut tmp_buf, gctx)
270270
.with_context(|| format!("failed to copy over vendored sources for: {}", id))?;
271271

272272
// Finally, emit the metadata about this package
273273
let json = serde_json::json!({
274274
"package": checksums.get(id),
275-
"files": map,
275+
"files": file_cksums,
276276
});
277277

278278
paths::write(&cksum, json.to_string())?;
@@ -347,9 +347,9 @@ fn sync(
347347
directory: opts.destination.to_string_lossy().replace("\\", "/"),
348348
},
349349
);
350-
} else if !dest_dir_already_exists {
350+
} else if !vendor_dir_already_exists {
351351
// Nothing to vendor. Remove the destination dir we've just created.
352-
paths::remove_dir(canonical_destination)?;
352+
paths::remove_dir(vendor_dir)?;
353353
}
354354

355355
Ok(VendorConfig { source: config })

0 commit comments

Comments
 (0)