Skip to content

Commit dc5149e

Browse files
authored
Merge pull request #224 from DominicLavery/main
fs: Fix #141 comparing symlink permissions
2 parents 7fe928e + 7501e42 commit dc5149e

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

fs/manifest_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ func TestManifestFromDir(t *testing.T) {
7575
actual.root.items["s"].(*directory).items["k"].(*file).content.Close()
7676
}
7777

78+
func TestSymlinks(t *testing.T) {
79+
rootDirectory := NewDir(t, "root",
80+
WithFile("foo.txt", "foo"),
81+
WithSymlink("foo.link", "foo.txt"))
82+
defer rootDirectory.Remove()
83+
expected := Expected(t,
84+
WithFile("foo.txt", "foo"),
85+
WithSymlink("foo.link", rootDirectory.Join("foo.txt")))
86+
assert.Assert(t, Equal(rootDirectory.Path(), expected))
87+
}
88+
7889
var cmpManifest = cmp.Options{
7990
cmp.AllowUnexported(Manifest{}, resource{}, file{}, symlink{}, directory{}),
8091
cmp.Comparer(func(x, y io.ReadCloser) bool {

fs/manifest_unix.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
//go:build !windows
12
// +build !windows
23

34
package fs
45

56
import (
67
"os"
8+
"runtime"
79
"syscall"
810
)
911

10-
const (
11-
defaultRootDirMode = os.ModeDir | 0700
12-
defaultSymlinkMode = os.ModeSymlink | 0777
13-
)
12+
const defaultRootDirMode = os.ModeDir | 0700
13+
14+
var defaultSymlinkMode = os.ModeSymlink | 0777
15+
16+
func init() {
17+
switch runtime.GOOS {
18+
case "darwin":
19+
defaultSymlinkMode = os.ModeSymlink | 0755
20+
}
21+
}
1422

1523
func newResourceFromInfo(info os.FileInfo) resource {
1624
statT := info.Sys().(*syscall.Stat_t)

0 commit comments

Comments
 (0)