File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,17 @@ func TestConn_Filename(t *testing.T) {
295
295
t .Parallel ()
296
296
297
297
file := filepath .Join (t .TempDir (), "test.db" )
298
+ f , err := os .Create (file )
299
+ if err != nil {
300
+ t .Fatal (err )
301
+ }
302
+ f .Close ()
303
+
304
+ file , err = filepath .EvalSymlinks (file )
305
+ if err != nil {
306
+ t .Fatal (err )
307
+ }
308
+
298
309
db , err := sqlite3 .Open (file )
299
310
if err != nil {
300
311
t .Fatal (err )
Original file line number Diff line number Diff line change @@ -13,22 +13,28 @@ import (
13
13
type vfsOS struct {}
14
14
15
15
func (vfsOS ) FullPathname (path string ) (string , error ) {
16
- path , err := filepath . Abs (path )
16
+ link , err := evalSymlinks (path )
17
17
if err != nil {
18
18
return "" , err
19
19
}
20
- return path , testSymlinks (filepath .Dir (path ))
20
+ full , err := filepath .Abs (link )
21
+ if err == nil && link != path {
22
+ err = _OK_SYMLINK
23
+ }
24
+ return full , err
21
25
}
22
26
23
- func testSymlinks (path string ) error {
24
- p , err := filepath .EvalSymlinks (path )
25
- if err != nil {
26
- return err
27
+ func evalSymlinks (path string ) (string , error ) {
28
+ var file string
29
+ _ , err := os .Lstat (path )
30
+ if errors .Is (err , fs .ErrNotExist ) {
31
+ path , file = filepath .Split (path )
27
32
}
28
- if p != path {
29
- return _OK_SYMLINK
33
+ path , err = filepath .EvalSymlinks (path )
34
+ if err != nil {
35
+ return "" , err
30
36
}
31
- return nil
37
+ return filepath . Join ( path , file ), nil
32
38
}
33
39
34
40
func (vfsOS ) Delete (path string , syncDir bool ) error {
You can’t perform that action at this time.
0 commit comments