fix: mkdir目录权限统一775
This commit is contained in:
@@ -34,7 +34,7 @@ const (
|
||||
// NewLogger 实例日志器对象
|
||||
func NewLogger(env, fileDir, fileName string, level, maxDay, maxSize int) (*Logger, error) {
|
||||
logFilePath := filepath.Join(fileDir, fileName)
|
||||
if err := os.MkdirAll(filepath.Dir(logFilePath), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(logFilePath), 0775); err != nil {
|
||||
return nil, fmt.Errorf("failed to mkdir logger dir: %v", err)
|
||||
}
|
||||
fileHandle, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
|
||||
@@ -20,7 +20,7 @@ func WriterFileCSV(data [][]string, filePath string) error {
|
||||
dirPath := filepath.Dir(filePath)
|
||||
|
||||
// 确保文件夹路径存在
|
||||
err := os.MkdirAll(dirPath, os.ModePerm)
|
||||
err := os.MkdirAll(dirPath, 0775)
|
||||
if err != nil {
|
||||
logger.Errorf("MkdirAll dir %v", err)
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func WriteSheet(headerCells map[string]string, dataCells []map[string]any, fileN
|
||||
saveFilePath := filepath.Join(dir, filePath, fileName)
|
||||
|
||||
// 创建文件目录
|
||||
if err := os.MkdirAll(filepath.Dir(saveFilePath), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(saveFilePath), 0775); err != nil {
|
||||
return "", fmt.Errorf("failed to create save file %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ func CopyUploadFile(filePath, dst string) error {
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(dst), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(dst), 0775); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ func WriterFileJSON(data any, filePath string) error {
|
||||
dirPath := filepath.Dir(filePath)
|
||||
|
||||
// 确保文件夹路径存在
|
||||
err := os.MkdirAll(dirPath, os.ModePerm)
|
||||
err := os.MkdirAll(dirPath, 0775)
|
||||
if err != nil {
|
||||
logger.Errorf("CreateFile MkdirAll %v", err)
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func WriterFileJSONLine(data []any, filePath string) error {
|
||||
dirPath := filepath.Dir(filePath)
|
||||
|
||||
// 确保文件夹路径存在
|
||||
err := os.MkdirAll(dirPath, os.ModePerm)
|
||||
err := os.MkdirAll(dirPath, 0775)
|
||||
if err != nil {
|
||||
logger.Errorf("CreateFile MkdirAll %v", err)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func WriterFileTXT(data [][]string, sep string, filePath string) error {
|
||||
dirPath := filepath.Dir(filePath)
|
||||
|
||||
// 确保文件夹路径存在
|
||||
err := os.MkdirAll(dirPath, os.ModePerm)
|
||||
err := os.MkdirAll(dirPath, 0775)
|
||||
if err != nil {
|
||||
logger.Errorf("CreateFile MkdirAll %v", err)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func transferToNewFile(file *multipart.FileHeader, dst string) error {
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
if err = os.MkdirAll(filepath.Dir(dst), 0750); err != nil {
|
||||
if err = os.MkdirAll(filepath.Dir(dst), 0775); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func mergeToNewFile(dirPath string, writePath string, fileName string) error {
|
||||
|
||||
// 写入到新路径文件
|
||||
newFilePath := filepath.Join(writePath, fileName)
|
||||
if err = os.MkdirAll(filepath.Dir(newFilePath), 0750); err != nil {
|
||||
if err = os.MkdirAll(filepath.Dir(newFilePath), 0775); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ func ConvertConfigToFile(configType, filePath string, data any) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(filePath), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(filePath), 0775); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(filePath, dataByte, 0644)
|
||||
|
||||
@@ -28,7 +28,7 @@ func FileSCPLocalToNe(neIp, localPath, nePath string) error {
|
||||
// 网元NE 远程文件复制到本地文件
|
||||
func FileSCPNeToLocal(neIp, nePath, localPath string) error {
|
||||
// 确保文件夹路径存在
|
||||
if err := os.MkdirAll(filepath.Dir(localPath), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(localPath), 0775); err != nil {
|
||||
logger.Errorf("FileSCPNeToLocal MkdirAll err %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ func (s *SSHClientSFTP) CopyDirRemoteToLocal(remoteDir, localDir string) error {
|
||||
}
|
||||
|
||||
// 创建本地目录
|
||||
err = os.MkdirAll(localDir, 0755)
|
||||
err = os.MkdirAll(localDir, 0775)
|
||||
if err != nil {
|
||||
logger.Errorf("CopyDirRemoteToLocal failed to creating local directory %s: => %s", localDir, err.Error())
|
||||
return err
|
||||
@@ -425,7 +425,7 @@ func (s *SSHClientSFTP) CopyFileRemoteToLocal(remotePath, localPath string) erro
|
||||
}
|
||||
defer remoteFile.Close()
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(localPath), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(localPath), 0775); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user