Skip to content

Commit

Permalink
Merge pull request #43 from PierreZ/fix/584458794
Browse files Browse the repository at this point in the history
Fix/584458794
  • Loading branch information
PierreZ committed Apr 8, 2022
2 parents dc205af + 66e167d commit ef9993e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
4 changes: 2 additions & 2 deletions foundationdb/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ mod boxed {
) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>>,
E: TransactError,
{
let r = (&mut f.f)(&trx, &mut f.d).await;
let r = (f.f)(&trx, &mut f.d).await;
(f, trx, r)
}

Expand Down Expand Up @@ -293,7 +293,7 @@ mod boxed_local {
) -> Pin<Box<dyn Future<Output = Result<T, E>> + 'a>>,
E: TransactError,
{
let r = (&mut f.f)(&trx, &mut f.d).await;
let r = (f.f)(&trx, &mut f.d).await;
(f, trx, r)
}

Expand Down
57 changes: 32 additions & 25 deletions foundationdb/src/directory/directory_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl DirectoryLayer {

let layer = layer.unwrap_or_default();

self.check_version(trx, allow_create).await?;
self.check_version(trx, true).await?;
let new_prefix = self.get_prefix(trx, prefix).await?;

let is_prefix_free = self
Expand Down Expand Up @@ -550,7 +550,7 @@ impl DirectoryLayer {
};
}

Ok(node.list_sub_folders(trx).await?)
node.list_sub_folders(trx).await
}

async fn move_to_internal(
Expand All @@ -567,35 +567,42 @@ impl DirectoryLayer {
return Err(DirectoryError::CannotMoveBetweenSubdirectory);
}

let old_node = self
.find(trx, old_path)
.await?
.ok_or(DirectoryError::PathDoesNotExists)?;
let old_node = self.find(trx, old_path).await?;
let new_node = self.find(trx, new_path).await?;

let old_node = match old_node {
None => return Err(DirectoryError::PathDoesNotExists),
Some(n) => n,
};
let old_node_exists_in_partition = old_node.is_in_partition(false);

if let Some(new_node) = self.find(trx, new_path).await? {
let new_node_exists_in_partition = new_node.is_in_partition(false);
if old_node_exists_in_partition || new_node_exists_in_partition {
if !old_node_exists_in_partition
|| !new_node_exists_in_partition
|| !old_node.current_path.eq(&new_node.current_path)
{
match new_node {
None => {
if old_node_exists_in_partition {
return Err(DirectoryError::CannotMoveBetweenPartition);
}

return new_node
.get_contents()?
.move_to(
trx,
&old_node.get_partition_subpath(),
&new_node.get_partition_subpath(),
)
.await;
}
Some(new_node) => {
let new_node_exists_in_partition = new_node.is_in_partition(false);
if old_node_exists_in_partition || new_node_exists_in_partition {
if !old_node_exists_in_partition
|| !new_node_exists_in_partition
|| !old_node.current_path.eq(&new_node.current_path)
{
return Err(DirectoryError::CannotMoveBetweenPartition);
}

return Err(DirectoryError::DirAlreadyExists);
} else if old_node_exists_in_partition {
return Err(DirectoryError::CannotMoveBetweenPartition);
return new_node
.get_contents()?
.move_to(
trx,
&old_node.get_partition_subpath(),
&new_node.get_partition_subpath(),
)
.await;
}
return Err(DirectoryError::DirAlreadyExists);
}
}

let (new_path_last, parent_path) = new_path
Expand Down
3 changes: 3 additions & 0 deletions scripts/run_bindingtester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ cd "${fdb_builddir:?}/foundationdb"
./bindings/bindingtester/bindingtester.py --num-ops 1000 --api-version 630 --test-name directory --concurrency 1 rust --no-directory-snapshot-ops --compare python --seed 1951034301
./bindings/bindingtester/bindingtester.py --num-ops 1000 --api-version 630 --test-name directory --concurrency 1 rust --no-directory-snapshot-ops --compare python --seed 1700644945

# https://github.com/foundationdb-rs/foundationdb-rs/issues/42
./bindings/bindingtester/bindingtester.py --num-ops 1000 --api-version 630 --test-name directory --concurrency 1 rust --no-directory-snapshot-ops --compare python --seed 584458794

START=1
END=${1-1}
for i in $(eval echo "{$START..$END}")
Expand Down

0 comments on commit ef9993e

Please sign in to comment.