Skip to content

Commit 0855800

Browse files
committed
Merge branch 'main' into feat/proton-drive
2 parents 1e0e498 + 4f8bc47 commit 0855800

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

drivers/local/driver.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,14 @@ func (d *Local) FileInfoToObj(ctx context.Context, f fs.FileInfo, reqPath string
146146
thumb += "?type=thumb&sign=" + sign.Sign(stdpath.Join(reqPath, f.Name()))
147147
}
148148
}
149-
isFolder := f.IsDir() || isSymlinkDir(f, fullPath)
149+
filePath := filepath.Join(fullPath, f.Name())
150+
isFolder := f.IsDir() || isLinkedDir(f, filePath)
150151
var size int64
151152
if !isFolder {
152153
size = f.Size()
153154
}
154155
var ctime time.Time
155-
t, err := times.Stat(stdpath.Join(fullPath, f.Name()))
156+
t, err := times.Stat(filePath)
156157
if err == nil {
157158
if t.HasBirthTime() {
158159
ctime = t.BirthTime()
@@ -161,7 +162,7 @@ func (d *Local) FileInfoToObj(ctx context.Context, f fs.FileInfo, reqPath string
161162

162163
file := model.ObjThumb{
163164
Object: model.Object{
164-
Path: filepath.Join(fullPath, f.Name()),
165+
Path: filePath,
165166
Name: f.Name(),
166167
Modified: f.ModTime(),
167168
Size: size,
@@ -197,7 +198,7 @@ func (d *Local) Get(ctx context.Context, path string) (model.Obj, error) {
197198
}
198199
return nil, err
199200
}
200-
isFolder := f.IsDir() || isSymlinkDir(f, path)
201+
isFolder := f.IsDir() || isLinkedDir(f, path)
201202
size := f.Size()
202203
if isFolder {
203204
size = 0

drivers/local/util.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io/fs"
88
"os"
99
"path/filepath"
10+
"runtime"
1011
"sort"
1112
"strconv"
1213
"strings"
@@ -18,14 +19,18 @@ import (
1819
ffmpeg "github.com/u2takey/ffmpeg-go"
1920
)
2021

21-
func isSymlinkDir(f fs.FileInfo, path string) bool {
22-
if f.Mode()&os.ModeSymlink == os.ModeSymlink {
23-
dst, err := os.Readlink(filepath.Join(path, f.Name()))
22+
func isLinkedDir(f fs.FileInfo, path string) bool {
23+
if f.Mode()&os.ModeSymlink == os.ModeSymlink || (runtime.GOOS == "windows" && f.Mode()&os.ModeIrregular != 0) {
24+
dst, err := os.Readlink(path)
2425
if err != nil {
2526
return false
2627
}
2728
if !filepath.IsAbs(dst) {
28-
dst = filepath.Join(path, dst)
29+
dst = filepath.Join(filepath.Dir(path), dst)
30+
}
31+
dst, err = filepath.Abs(dst)
32+
if err != nil {
33+
return false
2934
}
3035
stat, err := os.Stat(dst)
3136
if err != nil {

0 commit comments

Comments
 (0)