forked from mirrors/jj
store: make write_symlink()
async
This commit is contained in:
parent
4a8d250f2c
commit
bc06b2a442
4 changed files with 17 additions and 10 deletions
|
@ -721,7 +721,7 @@ impl TreeState {
|
|||
Ok(self.store.write_file(path, &mut file).await?)
|
||||
}
|
||||
|
||||
fn write_symlink_to_store(
|
||||
async fn write_symlink_to_store(
|
||||
&self,
|
||||
path: &RepoPath,
|
||||
disk_path: &Path,
|
||||
|
@ -737,7 +737,7 @@ impl TreeState {
|
|||
.ok_or_else(|| SnapshotError::InvalidUtf8SymlinkTarget {
|
||||
path: disk_path.to_path_buf(),
|
||||
})?;
|
||||
Ok(self.store.write_symlink(path, str_target)?)
|
||||
Ok(self.store.write_symlink(path, str_target).await?)
|
||||
} else {
|
||||
let target = fs::read(disk_path).map_err(|err| SnapshotError::Other {
|
||||
message: format!("Failed to read file {}", disk_path.display()),
|
||||
|
@ -747,7 +747,7 @@ impl TreeState {
|
|||
String::from_utf8(target).map_err(|_| SnapshotError::InvalidUtf8SymlinkTarget {
|
||||
path: disk_path.to_path_buf(),
|
||||
})?;
|
||||
Ok(self.store.write_symlink(path, &string_target)?)
|
||||
Ok(self.store.write_symlink(path, &string_target).await?)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1156,9 @@ impl TreeState {
|
|||
.write_path_to_store(repo_path, &disk_path, ¤t_tree_values, executable)
|
||||
.block_on()?,
|
||||
FileType::Symlink => {
|
||||
let id = self.write_symlink_to_store(repo_path, &disk_path)?;
|
||||
let id = self
|
||||
.write_symlink_to_store(repo_path, &disk_path)
|
||||
.block_on()?;
|
||||
Merge::normal(TreeValue::Symlink(id))
|
||||
}
|
||||
FileType::GitSubmodule => panic!("git submodule cannot be written to store"),
|
||||
|
|
|
@ -262,8 +262,8 @@ impl Store {
|
|||
self.backend.read_symlink(path, id).await
|
||||
}
|
||||
|
||||
pub fn write_symlink(&self, path: &RepoPath, contents: &str) -> BackendResult<SymlinkId> {
|
||||
self.backend.write_symlink(path, contents).block_on()
|
||||
pub async fn write_symlink(&self, path: &RepoPath, contents: &str) -> BackendResult<SymlinkId> {
|
||||
self.backend.write_symlink(path, contents).await
|
||||
}
|
||||
|
||||
pub fn read_conflict(
|
||||
|
|
|
@ -47,6 +47,7 @@ use jj_lib::working_copy::SnapshotOptions;
|
|||
use jj_lib::workspace::default_working_copy_factories;
|
||||
use jj_lib::workspace::LockedWorkspace;
|
||||
use jj_lib::workspace::Workspace;
|
||||
use pollster::FutureExt;
|
||||
use test_case::test_case;
|
||||
use testutils::commit_with_tree;
|
||||
use testutils::create_tree;
|
||||
|
@ -189,7 +190,7 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) {
|
|||
)
|
||||
}
|
||||
Kind::Symlink => {
|
||||
let id = store.write_symlink(path, "target").unwrap();
|
||||
let id = store.write_symlink(path, "target").block_on().unwrap();
|
||||
Merge::normal(TreeValue::Symlink(id))
|
||||
}
|
||||
Kind::Tree => {
|
||||
|
@ -501,7 +502,7 @@ fn test_conflicting_changes_on_disk() {
|
|||
updated_files: 0,
|
||||
added_files: 3,
|
||||
removed_files: 0,
|
||||
skipped_files: 3,
|
||||
skipped_files: 3
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -657,7 +658,7 @@ fn test_materialize_snapshot_conflicted_files() {
|
|||
updated_files: 0,
|
||||
added_files: 2,
|
||||
removed_files: 0,
|
||||
skipped_files: 0,
|
||||
skipped_files: 0
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -332,7 +332,11 @@ pub fn write_executable_file(tree_builder: &mut TreeBuilder, path: &RepoPath, co
|
|||
}
|
||||
|
||||
pub fn write_symlink(tree_builder: &mut TreeBuilder, path: &RepoPath, target: &str) {
|
||||
let id = tree_builder.store().write_symlink(path, target).unwrap();
|
||||
let id = tree_builder
|
||||
.store()
|
||||
.write_symlink(path, target)
|
||||
.block_on()
|
||||
.unwrap();
|
||||
tree_builder.set(path.to_owned(), TreeValue::Symlink(id));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue