filer: recursive deletion optionally ignoring any errors

fix https://github.com/chrislusf/seaweedfs/issues/1062
This commit is contained in:
Chris Lu
2019-09-11 20:26:20 -07:00
parent 5e9c65469e
commit ae53f63680
11 changed files with 130 additions and 114 deletions

View File

@@ -70,7 +70,7 @@ public class FilerClient {
}
public boolean rm(String path, boolean isRecursive) {
public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) {
Path pathObject = Paths.get(path);
String parent = pathObject.getParent().toString();
@@ -80,7 +80,8 @@ public class FilerClient {
parent,
name,
true,
isRecursive);
isRecursive,
ignoreRecusiveError);
}
public boolean touch(String path, int mode) {
@@ -229,13 +230,14 @@ public class FilerClient {
return true;
}
public boolean deleteEntry(String parent, String entryName, boolean isDeleteFileChunk, boolean isRecursive) {
public boolean deleteEntry(String parent, String entryName, boolean isDeleteFileChunk, boolean isRecursive, boolean ignoreRecusiveError) {
try {
filerGrpcClient.getBlockingStub().deleteEntry(FilerProto.DeleteEntryRequest.newBuilder()
.setDirectory(parent)
.setName(entryName)
.setIsDeleteData(isDeleteFileChunk)
.setIsRecursive(isRecursive)
.setIgnoreRecursiveError(ignoreRecusiveError)
.build());
} catch (Exception e) {
LOG.warn("deleteEntry {}/{}: {}", parent, entryName, e);

View File

@@ -141,6 +141,7 @@ message DeleteEntryRequest {
// bool is_directory = 3;
bool is_delete_data = 4;
bool is_recursive = 5;
bool ignore_recursive_error = 6;
}
message DeleteEntryResponse {

View File

@@ -106,7 +106,7 @@ public class SeaweedFileSystemStore {
}
}
return filerClient.deleteEntry(getParentDirectory(path), path.getName(), true, recursive);
return filerClient.deleteEntry(getParentDirectory(path), path.getName(), true, recursive, true);
}
private FileStatus doGetFileStatus(Path path, FilerProto.Entry entry) {

View File

@@ -106,7 +106,7 @@ public class SeaweedFileSystemStore {
}
}
return filerClient.deleteEntry(getParentDirectory(path), path.getName(), true, recursive);
return filerClient.deleteEntry(getParentDirectory(path), path.getName(), true, recursive, true);
}
private FileStatus doGetFileStatus(Path path, FilerProto.Entry entry) {