Skip to content

Commit 184cd96

Browse files
committed
debug: try write-write file lock.
1 parent b5b38a7 commit 184cd96

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

cite/git/src/repository/lock.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ pub(crate) struct Lock {
1515
pub lock_file: LockFile,
1616
}
1717

18+
/// NOTE: I just took a look at how Cargo is handling git concurrency, and they are not...
19+
///
20+
/// https://github.com/rust-lang/cargo/blob/3ceb2cb2504fed7446be428c3b8715b696161487/src/cargo/sources/git/source.rs#L445
21+
/// The clones are single threaded when constructing from the package manager.
22+
/// Subsequent revision specific activities are performed on locked copies of the repository.
1823
impl Lock {
1924
pub fn new(repository: Repository, lock_file: LockFile) -> Self {
2025
Self { repository, lock_file }

cite/git/src/repository/lock/lock_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl LockFile {
2929
/// This is optimistic - assumes the file already exists from a previous write operation.
3030
pub(crate) fn read(&self) -> Result<FileLock, GitSourceError> {
3131
// Read-only lock, no create - assumes file exists from previous write
32-
let options = FileOptions::new().write(true);
32+
let options = FileOptions::new().read(true).write(true); // DEBUG: it seems setting both read and write makes the lock work?
3333

3434
// lock is always blocking because this is for builds which don't have concurrency
3535
FileLock::lock(self.path.clone(), true, options).map_err(GitSourceError::CreateLockFile)

0 commit comments

Comments
 (0)