mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-19 14:34:20 +00:00
moved CryptoFolder.contains(Node) to Folder.isAncestorOf(Node), clarified a few javadocs
This commit is contained in:
@@ -15,7 +15,6 @@ import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@@ -146,15 +145,6 @@ class CryptoFolder extends CryptoNode implements Folder {
|
||||
physicalFolder().create(FolderCreateMode.INCLUDING_PARENTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(Folder target) {
|
||||
if (this.contains(target)) {
|
||||
throw new IllegalArgumentException("Can not copy parent to child directory (src: " + this + ", dst: " + target + ")");
|
||||
}
|
||||
|
||||
Folder.super.copyTo(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveTo(Folder target) {
|
||||
if (target instanceof CryptoFolder) {
|
||||
@@ -165,7 +155,7 @@ class CryptoFolder extends CryptoNode implements Folder {
|
||||
}
|
||||
|
||||
private void moveToInternal(CryptoFolder target) {
|
||||
if (this.contains(target) || target.contains(this)) {
|
||||
if (this.isAncestorOf(target) || target.isAncestorOf(this)) {
|
||||
throw new IllegalArgumentException("Can not move directories containing one another (src: " + this + ", dst: " + target + ")");
|
||||
}
|
||||
|
||||
@@ -180,17 +170,6 @@ class CryptoFolder extends CryptoNode implements Folder {
|
||||
directoryId.set(null);
|
||||
}
|
||||
|
||||
private boolean contains(Node node) {
|
||||
Optional<? extends Folder> nodeParent = node.parent();
|
||||
while (nodeParent.isPresent()) {
|
||||
if (this.equals(nodeParent.get())) {
|
||||
return true;
|
||||
}
|
||||
nodeParent = nodeParent.get().parent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Reference in New Issue
Block a user