符号链接支持,可以通过mklink(Windows)或者ln -s (Linux)将其他路径下的文件夹链接到根目录下而无需将文件复制到根目录下.针对删除场景特殊处理,删除整个符号链接目录不会删除链接目录内文件,仅删除链接,在符号链接目录操作同普通目录
This commit is contained in:
@ -240,7 +240,7 @@ func find(ctx context.Context, ss []string, fs FileSystem, name string) ([]strin
|
||||
return nil, err
|
||||
}
|
||||
ss = append(ss, name)
|
||||
if stat.IsDir() {
|
||||
if stat.IsDir() || (stat.Mode()&os.ModeSymlink > 0) {
|
||||
f, err := fs.OpenFile(ctx, name, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -480,7 +480,7 @@ func testFS(t *testing.T, fs FileSystem) {
|
||||
var stat os.FileInfo
|
||||
fileName := parts[0]
|
||||
if stat, opErr = fs.Stat(ctx, fileName); opErr == nil {
|
||||
if stat.IsDir() {
|
||||
if stat.IsDir() || (stat.Mode()&os.ModeSymlink > 0) {
|
||||
got = "dir"
|
||||
} else {
|
||||
got = strconv.Itoa(int(stat.Size()))
|
||||
@ -538,7 +538,7 @@ func TestMemFSRoot(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("i=%d: Stat: %v", i, err)
|
||||
}
|
||||
if !stat.IsDir() {
|
||||
if !stat.IsDir() && !(stat.Mode()&os.ModeSymlink > 0) {
|
||||
t.Fatalf("i=%d: Stat.IsDir is false, want true", i)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user