aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Barotin <jeromebarotin@gmail.com>2021-05-07 10:05:48 +0200
committerJérôme Barotin <jeromebarotin@gmail.com>2021-05-07 10:05:48 +0200
commit89b2ef8d055866933f72c8b4d4480585df0339ac (patch)
tree24a59e8e1d289d73c23551f7e37f1bdaf63b444d
parenta46be0ca5607d47daf64f63b6558bf70e6084951 (diff)
downloadseaweedfs-89b2ef8d055866933f72c8b4d4480585df0339ac.tar.xz
seaweedfs-89b2ef8d055866933f72c8b4d4480585df0339ac.zip
handle "/" in exist
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/FilerClient.java9
-rw-r--r--other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java3
2 files changed, 11 insertions, 1 deletions
diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
index de03efbb4..0a8356258 100644
--- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
+++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
@@ -128,7 +128,14 @@ public class FilerClient extends FilerGrpcClient {
public boolean exists(String path){
File pathFile = new File(path);
- return lookupEntry(pathFile.getParent(), pathFile.getName()) != null;
+ String parent = pathFile.getParent();
+ String entryName = pathFile.getName();
+ if(parent == null) {
+ parent = path;
+ entryName ="";
+ }
+ return lookupEntry(parent, entryName) != null;
+
}
public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) {
diff --git a/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java b/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java
index c45ce7a9d..f9a2c3f76 100644
--- a/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java
+++ b/other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java
@@ -25,5 +25,8 @@ public class SeaweedFilerTest {
if(filerClient.exists("/new_folder/new_empty_file")){
System.out.println("/new_folder/new_empty_file should not exists");
}
+ if(!filerClient.exists("/")){
+ System.out.println("/ should exists");
+ }
}
}