Skip to content

Commit a037c6e

Browse files
authored
Merge pull request #242 from Oxen-AI/windows-fix
Windows fix
2 parents f4521e1 + c2c05ac commit a037c6e

File tree

6 files changed

+34
-31
lines changed

6 files changed

+34
-31
lines changed

src/lib/src/api/local/branches.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ mod tests {
461461
// Make a dir
462462
let dir_path = Path::new("test_dir");
463463
let dir_repo_path = repo.path.join(dir_path);
464-
util::fs::create_dir_all(&dir_repo_path)?;
464+
util::fs::create_dir_all(dir_repo_path)?;
465465

466466
// File in the dir
467467
let file_path = dir_path.join(Path::new("test_file.txt"));
@@ -474,7 +474,7 @@ mod tests {
474474

475475
// New file in root
476476
let file_path_2 = Path::new("test_file_2.txt");
477-
let file_repo_path_2 = repo.path.join(&file_path_2);
477+
let file_repo_path_2 = repo.path.join(file_path_2);
478478
util::fs::write_to_path(&file_repo_path_2, "test")?;
479479

480480
// Add the file
@@ -483,9 +483,9 @@ mod tests {
483483

484484
// Now modify both files, add a third
485485
let file_path_3 = Path::new("test_file_3.txt");
486-
let file_repo_path_3 = repo.path.join(&file_path_3);
486+
let file_repo_path_3 = repo.path.join(file_path_3);
487487

488-
util::fs::write_to_path(&file_repo_path_3, "test 3")?;
488+
util::fs::write_to_path(file_repo_path_3, "test 3")?;
489489
util::fs::write_to_path(&file_repo_path_2, "something different now")?;
490490
util::fs::write_to_path(&file_repo_path, "something different now")?;
491491

@@ -494,22 +494,16 @@ mod tests {
494494

495495
let commit_3 = command::commit(&repo, "adding test file 2")?;
496496

497-
let branch = api::local::branches::get_by_name(&repo, DEFAULT_BRANCH_NAME)?.unwrap();
497+
let _branch = api::local::branches::get_by_name(&repo, DEFAULT_BRANCH_NAME)?.unwrap();
498498

499499
let file_versions =
500500
api::local::branches::list_entry_versions_on_branch(&repo, "main", &file_path)?;
501501

502-
let file_2_versions = api::local::branches::list_entry_versions_on_branch(
503-
&repo,
504-
"main",
505-
&file_path_2.to_path_buf(),
506-
)?;
502+
let file_2_versions =
503+
api::local::branches::list_entry_versions_on_branch(&repo, "main", file_path_2)?;
507504

508-
let file_3_versions = api::local::branches::list_entry_versions_on_branch(
509-
&repo,
510-
"main",
511-
&file_path_3.to_path_buf(),
512-
)?;
505+
let file_3_versions =
506+
api::local::branches::list_entry_versions_on_branch(&repo, "main", file_path_3)?;
513507

514508
assert_eq!(file_versions.len(), 2);
515509
assert_eq!(file_versions[0].0.id, commit_3.id);
@@ -549,8 +543,8 @@ mod tests {
549543

550544
// Add an irrelevant file - aka this isn't changing for commit 3
551545
let file_path_2 = Path::new("test_file_2.txt");
552-
let file_repo_path_2 = repo.path.join(&file_path_2);
553-
util::fs::write_to_path(&file_repo_path_2, "test")?;
546+
let file_repo_path_2 = repo.path.join(file_path_2);
547+
util::fs::write_to_path(file_repo_path_2, "test")?;
554548
command::add(&repo, &repo.path)?;
555549
let _commit_3 = command::commit(&repo, "adding test file 3")?;
556550

@@ -578,8 +572,8 @@ mod tests {
578572
command::add(&repo, &repo.path)?;
579573
let commit_6 = command::commit(&repo, "adding test file 6")?;
580574

581-
let main = api::local::branches::get_by_name(&repo, DEFAULT_BRANCH_NAME)?.unwrap();
582-
let branch = api::local::branches::get_by_name(&repo, "test_branch")?.unwrap();
575+
let _main = api::local::branches::get_by_name(&repo, DEFAULT_BRANCH_NAME)?.unwrap();
576+
let _branch = api::local::branches::get_by_name(&repo, "test_branch")?.unwrap();
583577
let main_versions =
584578
api::local::branches::list_entry_versions_on_branch(&repo, "main", &file_path)?;
585579

src/lib/src/api/remote/commits.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,20 @@ pub async fn download_commit_entries_db_to_path(
594594
util::fs::remove_dir_all(&full_unpacked_path)?;
595595
} else {
596596
log::debug!("{} creating {:?}", current_function!(), full_unpacked_path);
597-
std::fs::create_dir_all(&full_unpacked_path)?;
597+
if let Some(parent) = full_unpacked_path.parent() {
598+
std::fs::create_dir_all(parent)?;
599+
} else {
600+
log::error!(
601+
"{} no parent found for {:?}",
602+
current_function!(),
603+
full_unpacked_path
604+
);
605+
}
598606
}
599607

600608
// Move the tmp path to the full path
601609
log::debug!("renaming {:?} to {:?}", tmp_path, full_unpacked_path);
610+
602611
std::fs::rename(
603612
tmp_path.join(HISTORY_DIR).join(commit_id),
604613
&full_unpacked_path,

src/lib/src/core/index/commit_dir_entry_reader.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ impl CommitDirEntryReader {
132132

133133
pub fn has_file<P: AsRef<Path>>(&self, path: P) -> bool {
134134
let full_path = self.dir.join(path.as_ref());
135-
let path_hash_prefix = util::hasher::hash_path(&full_path)[0..2].to_string();
135+
let path_hash_prefix = util::hasher::hash_path(full_path)[0..2].to_string();
136136

137-
log::debug!(
138-
"has_file looking for this path hash prefix {:?} for {:?}",
139-
path_hash_prefix,
140-
full_path
141-
);
137+
// log::debug!(
138+
// "has_file looking for this path hash prefix {:?} for {:?}",
139+
// path_hash_prefix,
140+
// full_path
141+
// );
142142

143143
// Binary search for the appropriate vnode
144144
let vnode_child = self
@@ -177,7 +177,7 @@ impl CommitDirEntryReader {
177177
return false;
178178
};
179179

180-
log::debug!("has_file found file {:?}", file);
180+
// log::debug!("has_file found file {:?}", file);
181181

182182
matches!(file, TreeObjectChild::File { .. })
183183
}

src/lib/src/core/index/entry_indexer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl EntryIndexer {
753753
entries.par_iter().for_each(|entry| {
754754
let filepath = self.repository.path.join(entry.path());
755755
if versioner::should_unpack_entry(entry, &filepath) {
756-
log::debug!("pull_entries_for_commit unpack {:?}", entry.path());
756+
// log::debug!("pull_entries_for_commit unpack {:?}", entry.path());
757757
let version_path = util::fs::version_path_for_entry(&self.repository, entry);
758758
match util::fs::copy_mkdir(version_path, &filepath) {
759759
Ok(_) => {}
@@ -919,7 +919,7 @@ impl EntryIndexer {
919919
})
920920
})
921921
{
922-
log::debug!("cleanup_removed_entries : {:?}", dir_entry_result);
922+
// log::debug!("cleanup_removed_entries : {:?}", dir_entry_result);
923923
match dir_entry_result {
924924
Ok(dir_entry) => {
925925
if let Some(was_removed) = &dir_entry.client_state {

src/lib/src/core/index/puller.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub async fn pull_entries(
3333
}
3434

3535
let missing_entries = get_missing_entries(entries, &dst);
36-
log::debug!("Pulling missing entries {:?}", missing_entries);
36+
// log::debug!("Pulling missing entries {:?}", missing_entries);
3737

3838
if missing_entries.is_empty() {
3939
return Ok(());

tests/test_push_pull.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::Path;
22

33
use liboxen::api;
4-
use liboxen::api::remote;
4+
55
use liboxen::command;
66
use liboxen::constants;
77
use liboxen::constants::DEFAULT_BRANCH_NAME;

0 commit comments

Comments
 (0)