}
dir = ".."
parts = []string{filepath.Base(wd)}
- } else if parts[0] != "." {
+ } else {
// Relative path: start at the current directory
dir = "."
+ if parts[0] == "." {
+ parts = parts[1:]
+ }
}
dirFd, err := unix.Openat(unix.AT_FDCWD, dir, openReadonlyFlags, 0)
fmt.Errorf("symlink not permitted in path: \"dir\""),
},
+ // Border cases
+
+ {
+ "relative path with leading dot",
+ safcm.MsgSyncReq{},
+ &safcm.File{
+ Path: "./dir/file",
+ Mode: 0644,
+ Uid: -1,
+ Gid: -1,
+ OrigGroup: "group",
+ Data: []byte("content"),
+ },
+ func() {
+ ft.CreateDirectory("dir", 0755)
+ },
+ true,
+ []ft.File{
+ root,
+ {
+ Path: "dir",
+ Mode: fs.ModeDir | 0755,
+ },
+ {
+ Path: "dir/file",
+ Mode: 0644,
+ Data: []byte("content"),
+ },
+ },
+ safcm.MsgSyncResp{
+ FileChanges: []safcm.FileChange{
+ {
+ Path: "./dir/file",
+ Created: true,
+ New: safcm.FileChangeInfo{
+ Mode: 0644,
+ User: user,
+ Uid: uid,
+ Group: group,
+ Gid: gid,
+ },
+ },
+ },
+ },
+ []string{
+ `4: files: "./dir/file" (group): will create`,
+ `3: files: "./dir/file" (group): creating`,
+ `4: files: "./dir/file" (group): creating temporary file "dir/.file*"`,
+ `4: files: "./dir/file" (group): renaming "dir/.fileRND"`,
+ },
+ nil,
+ },
+
// Diffs
{