File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,10 @@ package php
24
24
25
25
import (
26
26
"os"
27
+ "path/filepath"
27
28
"syscall"
29
+
30
+ "github.com/pkg/errors"
28
31
)
29
32
30
33
func shouldSignalBeIgnored (sig os.Signal ) bool {
@@ -34,5 +37,13 @@ func shouldSignalBeIgnored(sig os.Signal) bool {
34
37
}
35
38
36
39
func symlink (oldname , newname string ) error {
37
- return os .Symlink (oldname , newname )
40
+ err := errors .WithStack (os .Symlink (oldname , newname ))
41
+
42
+ if os .IsExist (errors .Cause (err )) {
43
+ if target , _ := filepath .EvalSymlinks (newname ); target == oldname {
44
+ return nil
45
+ }
46
+ }
47
+
48
+ return err
38
49
}
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ package php
22
22
import (
23
23
"io"
24
24
"os"
25
+
26
+ "github.com/pkg/errors"
25
27
)
26
28
27
29
func shouldSignalBeIgnored (sig os.Signal ) bool {
@@ -31,14 +33,14 @@ func shouldSignalBeIgnored(sig os.Signal) bool {
31
33
func symlink (oldname , newname string ) error {
32
34
source , err := os .Open (oldname )
33
35
if err != nil {
34
- return err
36
+ return errors . WithStack ( err )
35
37
}
36
38
defer source .Close ()
37
39
destination , err := os .Create (newname )
38
40
if err != nil {
39
- return err
41
+ return errors . WithStack ( err )
40
42
}
41
43
defer destination .Close ()
42
44
_ , err = io .Copy (destination , source )
43
- return err
45
+ return errors . WithStack ( err )
44
46
}
You can’t perform that action at this time.
0 commit comments