From e06006ea28a2b25319d4bc0d94d94079971a39af Mon Sep 17 00:00:00 2001 From: Changxin Miao Date: Mon, 25 May 2020 12:07:25 +0800 Subject: [PATCH] pkg: Fix dir permission check on Windows --- pkg/fileutil/dir_unix.go | 5 +++++ pkg/fileutil/dir_windows.go | 5 +++++ pkg/fileutil/fileutil.go | 2 -- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/fileutil/dir_unix.go b/pkg/fileutil/dir_unix.go index 58a77dfc1a9..4ce15dc6bcf 100644 --- a/pkg/fileutil/dir_unix.go +++ b/pkg/fileutil/dir_unix.go @@ -18,5 +18,10 @@ package fileutil import "os" +const ( + // PrivateDirMode grants owner to make/remove files inside the directory. + PrivateDirMode = 0700 +) + // OpenDir opens a directory for syncing. func OpenDir(path string) (*os.File, error) { return os.Open(path) } diff --git a/pkg/fileutil/dir_windows.go b/pkg/fileutil/dir_windows.go index c123395c004..a10a90583c7 100644 --- a/pkg/fileutil/dir_windows.go +++ b/pkg/fileutil/dir_windows.go @@ -21,6 +21,11 @@ import ( "syscall" ) +const ( + // PrivateDirMode grants owner to make/remove files inside the directory. + PrivateDirMode = 0777 +) + // OpenDir opens a directory in windows with write access for syncing. func OpenDir(path string) (*os.File, error) { fd, err := openDir(path) diff --git a/pkg/fileutil/fileutil.go b/pkg/fileutil/fileutil.go index a4194fdf19c..1358ba28d32 100644 --- a/pkg/fileutil/fileutil.go +++ b/pkg/fileutil/fileutil.go @@ -25,8 +25,6 @@ import ( const ( // PrivateFileMode grants owner to read/write a file. PrivateFileMode = 0600 - // PrivateDirMode grants owner to make/remove files inside the directory. - PrivateDirMode = 0700 ) // IsDirWriteable checks if dir is writable by writing and removing a file