fix: 导出备份配置调整
This commit is contained in:
@@ -8,21 +8,19 @@ import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
)
|
||||
|
||||
type FileInfo struct {
|
||||
FileType string `json:"fileType"` // 文件类型
|
||||
FileMode string `json:"fileMode"` // 文件的权限
|
||||
LinkCount int64 `json:"linkCount"` // 硬链接数目
|
||||
Owner string `json:"owner"` // 所属用户
|
||||
Group string `json:"group"` // 所属组
|
||||
Size string `json:"size"` // 文件的大小
|
||||
ModifiedTime int64 `json:"modifiedTime"` // 最后修改时间,单位为秒
|
||||
FileName string `json:"fileName"` // 文件的名称
|
||||
FileType string `json:"fileType"` // file type: file/directory
|
||||
FileMode string `json:"fileMode"` // file mode
|
||||
LinkCount int64 `json:"linkCount"` // link count
|
||||
Owner string `json:"owner"` // owner
|
||||
Group string `json:"group"` // group
|
||||
Size int64 `json:"size"` // size: xx byte
|
||||
ModifiedTime int64 `json:"modifiedTime"` // last modified time:seconds
|
||||
FilePath string `json:"filePath"` // file path
|
||||
FileName string `json:"fileName"` // file name
|
||||
}
|
||||
|
||||
func GetFileInfo(dir, suffix string) ([]FileInfo, error) {
|
||||
@@ -58,15 +56,15 @@ func GetFileInfo(dir, suffix string) ([]FileInfo, error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
humanReadableSize := humanize.Bytes(uint64(info.Size()))
|
||||
fileInfo := FileInfo{
|
||||
FileType: fileType,
|
||||
FileMode: info.Mode().String(),
|
||||
LinkCount: int64(info.Sys().(*syscall.Stat_t).Nlink),
|
||||
Owner: userInfo.Username,
|
||||
Group: groupInfo.Name,
|
||||
Size: strings.ToUpper(humanReadableSize),
|
||||
Size: info.Size(),
|
||||
ModifiedTime: info.ModTime().Unix(),
|
||||
FilePath: dir,
|
||||
FileName: info.Name(),
|
||||
}
|
||||
files = append(files, fileInfo)
|
||||
|
||||
Reference in New Issue
Block a user