use basic file object to parse path

fix https://github.com/chrislusf/seaweedfs/issues/1825
This commit is contained in:
Chris Lu 2021-02-21 19:27:38 -08:00
parent 258e93bc86
commit d493d626ba

View file

@ -4,8 +4,7 @@ import com.google.common.base.Strings;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.nio.file.Path; import java.io.File;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
@ -94,9 +93,9 @@ public class FilerClient extends FilerGrpcClient {
if ("/".equals(path)) { if ("/".equals(path)) {
return true; return true;
} }
Path pathObject = Paths.get(path); File pathFile = new File(path);
String parent = pathObject.getParent().toString(); String parent = pathFile.getParent();
String name = pathObject.getFileName().toString(); String name = pathFile.getName();
mkdirs(parent, mode, uid, gid, userName, groupNames); mkdirs(parent, mode, uid, gid, userName, groupNames);
@ -115,13 +114,13 @@ public class FilerClient extends FilerGrpcClient {
public boolean mv(String oldPath, String newPath) { public boolean mv(String oldPath, String newPath) {
Path oldPathObject = Paths.get(oldPath); File oldPathFile = new File(oldPath);
String oldParent = oldPathObject.getParent().toString(); String oldParent = oldPathFile.getParent();
String oldName = oldPathObject.getFileName().toString(); String oldName = oldPathFile.getName();
Path newPathObject = Paths.get(newPath); File newPathFile = new File(newPath);
String newParent = newPathObject.getParent().toString(); String newParent = newPathFile.getParent();
String newName = newPathObject.getFileName().toString(); String newName = newPathFile.getName();
return atomicRenameEntry(oldParent, oldName, newParent, newName); return atomicRenameEntry(oldParent, oldName, newParent, newName);
@ -129,9 +128,9 @@ public class FilerClient extends FilerGrpcClient {
public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) { public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) {
Path pathObject = Paths.get(path); File pathFile = new File(path);
String parent = pathObject.getParent().toString(); String parent = pathFile.getParent();
String name = pathObject.getFileName().toString(); String name = pathFile.getName();
return deleteEntry( return deleteEntry(
parent, parent,
@ -148,9 +147,9 @@ public class FilerClient extends FilerGrpcClient {
public boolean touch(String path, int mode, int uid, int gid, String userName, String[] groupNames) { public boolean touch(String path, int mode, int uid, int gid, String userName, String[] groupNames) {
Path pathObject = Paths.get(path); File pathFile = new File(path);
String parent = pathObject.getParent().toString(); String parent = pathFile.getParent();
String name = pathObject.getFileName().toString(); String name = pathFile.getName();
FilerProto.Entry entry = lookupEntry(parent, name); FilerProto.Entry entry = lookupEntry(parent, name);
if (entry == null) { if (entry == null) {