Skip to content

Commit

Permalink
fix(directory): properly handle list with nested directory partition
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreZ committed Jun 21, 2021
1 parent 1e46135 commit 9ba2124
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion foundationdb-bindingtester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ The following configurations are tested and should pass without any issue:

## Directory faulty seed

* Completed directory test with random seed 2807298642 and 849 operations (bad layer, path and list child)
* Completed directory test with random seed 3642303358 and 6538 operations (should fire directory errors)
19 changes: 13 additions & 6 deletions foundationdb/src/directory/directory_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,27 +564,34 @@ impl DirectoryLayer {
trx: &Transaction,
path: Vec<String>,
) -> Result<Vec<String>, DirectoryError> {
println!("listing path {:?} with self.path={:?}", &path, &self.path);
self.check_version(trx, false).await?;

let node = self.find(trx, path.to_owned()).await?;
if !node.exists() {
return Err(DirectoryError::PathDoesNotExists);
}
if node.is_in_partition(false) {
if node.is_in_partition(true) {
let subspace_node = match node.subspace {
// not reachable because `self.find` is creating a node with a subspace.
None => unreachable!("node's subspace is not set"),
Some(ref s) => s.clone(),
};

let directory_partition = self.contents_of_node(
match self.contents_of_node(
subspace_node,
node.current_path.to_owned(),
node.layer.to_owned(),
)?;
return directory_partition
.list(trx, node.get_partition_subpath())
.await;
)? {
DirectoryOutput::DirectorySubspace(_) => unreachable!("already in partition"),
DirectoryOutput::DirectoryPartition(directory_partition) => {
return directory_partition
.directory_subspace
.directory_layer
.list(trx, node.get_partition_subpath())
.await
}
};
}

Ok(node.list_sub_folders(trx).await?)
Expand Down

0 comments on commit 9ba2124

Please sign in to comment.