Skip to content

Commit

Permalink
Merge pull request #224 from DominicLavery/main
Browse files Browse the repository at this point in the history
fs: Fix #141 comparing symlink permissions
  • Loading branch information
dnephin authored Jan 15, 2022
2 parents 7fe928e + 7501e42 commit dc5149e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 11 additions & 0 deletions fs/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ func TestManifestFromDir(t *testing.T) {
actual.root.items["s"].(*directory).items["k"].(*file).content.Close()
}

func TestSymlinks(t *testing.T) {
rootDirectory := NewDir(t, "root",
WithFile("foo.txt", "foo"),
WithSymlink("foo.link", "foo.txt"))
defer rootDirectory.Remove()
expected := Expected(t,
WithFile("foo.txt", "foo"),
WithSymlink("foo.link", rootDirectory.Join("foo.txt")))
assert.Assert(t, Equal(rootDirectory.Path(), expected))
}

var cmpManifest = cmp.Options{
cmp.AllowUnexported(Manifest{}, resource{}, file{}, symlink{}, directory{}),
cmp.Comparer(func(x, y io.ReadCloser) bool {
Expand Down
16 changes: 12 additions & 4 deletions fs/manifest_unix.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
//go:build !windows
// +build !windows

package fs

import (
"os"
"runtime"
"syscall"
)

const (
defaultRootDirMode = os.ModeDir | 0700
defaultSymlinkMode = os.ModeSymlink | 0777
)
const defaultRootDirMode = os.ModeDir | 0700

var defaultSymlinkMode = os.ModeSymlink | 0777

func init() {
switch runtime.GOOS {
case "darwin":
defaultSymlinkMode = os.ModeSymlink | 0755
}
}

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

0 comments on commit dc5149e

Please sign in to comment.