Browse Source

Add exists() to java client

pull/2052/head
Jérôme Barotin 4 years ago
parent
commit
a46be0ca56
  1. 5
      other/java/client/src/main/java/seaweedfs/client/FilerClient.java
  2. 8
      other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java

5
other/java/client/src/main/java/seaweedfs/client/FilerClient.java

@ -126,6 +126,11 @@ public class FilerClient extends FilerGrpcClient {
} }
public boolean exists(String path){
File pathFile = new File(path);
return lookupEntry(pathFile.getParent(), pathFile.getName()) != null;
}
public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) { public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) {
File pathFile = new File(path); File pathFile = new File(path);

8
other/java/client/src/test/java/seaweedfs/client/SeaweedFilerTest.java

@ -16,8 +16,14 @@ public class SeaweedFilerTest {
filerClient.mkdirs("/new_folder", 0755); filerClient.mkdirs("/new_folder", 0755);
filerClient.touch("/new_folder/new_empty_file", 0755); filerClient.touch("/new_folder/new_empty_file", 0755);
filerClient.touch("/new_folder/new_empty_file2", 0755); filerClient.touch("/new_folder/new_empty_file2", 0755);
if(!filerClient.exists("/new_folder/new_empty_file")){
System.out.println("/new_folder/new_empty_file should exists");
}
filerClient.rm("/new_folder/new_empty_file", false, true); filerClient.rm("/new_folder/new_empty_file", false, true);
filerClient.rm("/new_folder", true, true); filerClient.rm("/new_folder", true, true);
if(filerClient.exists("/new_folder/new_empty_file")){
System.out.println("/new_folder/new_empty_file should not exists");
}
} }
} }
Loading…
Cancel
Save