Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add modTime on folder creation #334

Merged
merged 2 commits into from Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mem/file.go
Expand Up @@ -71,7 +71,7 @@ func CreateFile(name string) *FileData {
}

func CreateDir(name string) *FileData {
return &FileData{name: name, memDir: &DirMap{}, dir: true}
return &FileData{name: name, memDir: &DirMap{}, dir: true, modtime: time.Now()}
}

func ChangeFileName(f *FileData, newname string) {
Expand Down
9 changes: 9 additions & 0 deletions memmap_test.go
Expand Up @@ -450,6 +450,9 @@ func TestMemFsMkdirAllMode(t *testing.T) {
if !info.Mode().IsDir() {
t.Error("/a: mode is not directory")
}
if !info.ModTime().After(time.Now().Add(-1 * time.Hour)) {
t.Errorf("/a: mod time not set, got %s", info.ModTime())
}
if info.Mode() != os.FileMode(os.ModeDir|0755) {
t.Errorf("/a: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
}
Expand All @@ -463,6 +466,9 @@ func TestMemFsMkdirAllMode(t *testing.T) {
if info.Mode() != os.FileMode(os.ModeDir|0755) {
t.Errorf("/a/b: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
}
if !info.ModTime().After(time.Now().Add(-1 * time.Hour)) {
t.Errorf("/a/b: mod time not set, got %s", info.ModTime())
}
info, err = fs.Stat("/a/b/c")
if err != nil {
t.Fatal(err)
Expand All @@ -473,6 +479,9 @@ func TestMemFsMkdirAllMode(t *testing.T) {
if info.Mode() != os.FileMode(os.ModeDir|0755) {
t.Errorf("/a/b/c: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
}
if !info.ModTime().After(time.Now().Add(-1 * time.Hour)) {
t.Errorf("/a/b/c: mod time not set, got %s", info.ModTime())
}
}

// MkdirAll does not change permissions of already-existing directories
Expand Down