From e509fb0571f5fcba6c5fd30d8555ff39500d3099 Mon Sep 17 00:00:00 2001
From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com>
Date: Tue, 5 Sep 2023 18:34:11 +0800
Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=87=E4=BB=B6=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0=20uid=20=E5=92=8C=20gid=20=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=20(#2192)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Refs https://github.com/1Panel-dev/1Panel/issues/2066
---
backend/utils/files/fileinfo.go | 7 +++++++
frontend/src/api/interface/file.ts | 2 ++
frontend/src/views/host/file-management/index.vue | 8 ++++++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/backend/utils/files/fileinfo.go b/backend/utils/files/fileinfo.go
index 9a984a0f0..e4709bf1c 100644
--- a/backend/utils/files/fileinfo.go
+++ b/backend/utils/files/fileinfo.go
@@ -10,6 +10,7 @@ import (
"os/exec"
"path"
"path/filepath"
+ "strconv"
"strings"
"syscall"
"time"
@@ -23,6 +24,8 @@ type FileInfo struct {
Name string `json:"name"`
User string `json:"user"`
Group string `json:"group"`
+ Uid string `json:"uid"`
+ Gid string `json:"gid"`
Extension string `json:"extension"`
Content string `json:"content"`
Size int64 `json:"size"`
@@ -77,6 +80,8 @@ func NewFileInfo(op FileOption) (*FileInfo, error) {
IsHidden: IsHidden(op.Path),
Mode: fmt.Sprintf("%04o", info.Mode().Perm()),
User: GetUsername(info.Sys().(*syscall.Stat_t).Uid),
+ Uid: strconv.FormatUint(uint64(info.Sys().(*syscall.Stat_t).Uid), 10),
+ Gid: strconv.FormatUint(uint64(info.Sys().(*syscall.Stat_t).Gid), 10),
Group: GetGroup(info.Sys().(*syscall.Stat_t).Gid),
MimeType: GetMimeType(op.Path),
}
@@ -208,6 +213,8 @@ func (f *FileInfo) listChildren(dir, showHidden, containSub bool, search string,
Mode: fmt.Sprintf("%04o", df.Mode().Perm()),
User: GetUsername(df.Sys().(*syscall.Stat_t).Uid),
Group: GetGroup(df.Sys().(*syscall.Stat_t).Gid),
+ Uid: strconv.FormatUint(uint64(df.Sys().(*syscall.Stat_t).Uid), 10),
+ Gid: strconv.FormatUint(uint64(df.Sys().(*syscall.Stat_t).Gid), 10),
}
if isSymlink {
diff --git a/frontend/src/api/interface/file.ts b/frontend/src/api/interface/file.ts
index f0ad5b810..acc2f8f12 100644
--- a/frontend/src/api/interface/file.ts
+++ b/frontend/src/api/interface/file.ts
@@ -5,6 +5,8 @@ export namespace File {
name: string;
user: string;
group: string;
+ uid: number;
+ gid: number;
content: string;
size: number;
isDir: boolean;
diff --git a/frontend/src/views/host/file-management/index.vue b/frontend/src/views/host/file-management/index.vue
index 7339aa4b2..4f3f94ee6 100644
--- a/frontend/src/views/host/file-management/index.vue
+++ b/frontend/src/views/host/file-management/index.vue
@@ -128,12 +128,16 @@
- {{ row.user }}
+
+ {{ row.user ? row.user : '-' }} ({{ row.uid }})
+
- {{ row.group }}
+
+ {{ row.group ? row.group : '-' }} ({{ row.gid }})
+