You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: assure duplicate packs and indices aren't overwriting existing ones (#1404).
That way, on Windows there is no chance for access-denied errors.
Maybe there are other advantages as well even for Unix.
Since packs are usually written rarely, in comparison to loose objects,
the extra file accesss seems acceptable.
Copy file name to clipboardExpand all lines: gix-pack/src/bundle/write/mod.rs
+24-15
Original file line number
Diff line number
Diff line change
@@ -310,26 +310,35 @@ impl crate::Bundle {
310
310
}else{
311
311
let data_path = directory.join(format!("pack-{}.pack", outcome.data_hash.to_hex()));
312
312
let index_path = data_path.with_extension("idx");
313
-
let keep_path = data_path.with_extension("keep");
313
+
let keep_path = if data_path.is_file(){
314
+
// avoid trying to overwrite existing files, we know they have the same content
315
+
// and this is likely to fail on Windows as negotiation opened the pack.
316
+
None
317
+
}else{
318
+
let keep_path = data_path.with_extension("keep");
314
319
315
-
std::fs::write(&keep_path,b"")?;
316
-
Arc::try_unwrap(data_file)
317
-
.expect("only one handle left after pack was consumed")
318
-
.into_inner()
319
-
.into_inner()
320
-
.map_err(|err| Error::from(err.into_error()))?
321
-
.persist(&data_path)?;
322
-
index_file
323
-
.persist(&index_path)
324
-
.map_err(|err| {
325
-
gix_features::trace::warn!("pack file at \"{}\" is retained despite failing to move the index file into place. You can use plumbing to make it usable.",data_path.display());
326
-
err
327
-
})?;
320
+
std::fs::write(&keep_path,b"")?;
321
+
Arc::try_unwrap(data_file)
322
+
.expect("only one handle left after pack was consumed")
323
+
.into_inner()
324
+
.into_inner()
325
+
.map_err(|err| Error::from(err.into_error()))?
326
+
.persist(&data_path)?;
327
+
Some(keep_path)
328
+
};
329
+
if !index_path.is_file(){
330
+
index_file
331
+
.persist(&index_path)
332
+
.map_err(|err| {
333
+
gix_features::trace::warn!("pack file at \"{}\" is retained despite failing to move the index file into place. You can use plumbing to make it usable.",data_path.display());
0 commit comments