fix(file): fix issue with copy file failed (#8153)

This commit is contained in:
zhengkunwang 2025-03-14 14:51:08 +08:00 committed by GitHub
parent 7eeca73337
commit 80a0afc135
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 6 deletions

View file

@ -768,8 +768,12 @@ func (b *BaseApi) ProcessKeys(c *gin.Context) {
continue
}
var process files.Process
if err := json.Unmarshal([]byte(value), &process); err == nil && process.Percent != 100 {
res.Keys = append(res.Keys, key)
if err := json.Unmarshal([]byte(value), &process); err != nil {
continue
}
res.Keys = append(res.Keys, key)
if process.Percent == 100 {
global.CACHE.Del(key)
}
}
helper.SuccessWithData(c, res)

View file

@ -7,6 +7,7 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"github.com/1Panel-dev/1Panel/agent/buserr"
"io"
"io/fs"
"net/http"
@ -394,10 +395,7 @@ func (f FileOp) CopyAndReName(src, dst, name string, cover bool) error {
if dst = path.Clean("/" + dst); dst == "" {
return os.ErrNotExist
}
if src == "/" || dst == "/" {
return os.ErrInvalid
}
if dst == src {
if src == "/" || dst == src {
return os.ErrInvalid
}
@ -406,6 +404,12 @@ func (f FileOp) CopyAndReName(src, dst, name string, cover bool) error {
return err
}
if name != "" && !cover {
if f.Stat(filepath.Join(dst, name)) {
return buserr.New("ErrFileIsExist")
}
}
if srcInfo.IsDir() {
dstPath := dst
if name != "" && !cover {

View file

@ -437,6 +437,7 @@ const initEditor = () => {
minimap: {
enabled: config.minimap,
},
lineNumbersMinChars: 6,
});
if (editor.getModel().getValue() === '') {
let defaultContent = '\n\n\n\n';

View file

@ -763,10 +763,14 @@ const openProcess = () => {
const closeProcess = () => {
search();
getWgetProcess();
setTimeout(() => {
getWgetProcess();
}, 1000);
};
const processCount = ref(0);
const getWgetProcess = async () => {
processCount.value = 0;
try {
const res = await fileWgetKeys();
if (res.data && res.data.keys.length > 0) {