diff --git a/backend/utils/files/file_op.go b/backend/utils/files/file_op.go index 9b85138a4..d93c15dcc 100644 --- a/backend/utils/files/file_op.go +++ b/backend/utils/files/file_op.go @@ -322,17 +322,21 @@ func (f FileOp) CopyFile(src, dst string) error { } defer srcFile.Close() - err = f.Fs.MkdirAll(filepath.Dir(dst), 0666) + srcInfo, err := f.Fs.Stat(src) if err != nil { return err } + dstPath := path.Join(dst, srcInfo.Name()) + if src == dstPath { + return nil + } - srcInfo, err := f.Fs.Stat(src) + err = f.Fs.MkdirAll(filepath.Dir(dst), 0666) if err != nil { return err } - dstFile, err := f.Fs.OpenFile(path.Join(dst, srcInfo.Name()), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775) + dstFile, err := f.Fs.OpenFile(dstPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775) if err != nil { return err } diff --git a/frontend/src/views/host/file-management/code-editor/index.vue b/frontend/src/views/host/file-management/code-editor/index.vue index 7e9767e52..03b96c91d 100644 --- a/frontend/src/views/host/file-management/code-editor/index.vue +++ b/frontend/src/views/host/file-management/code-editor/index.vue @@ -82,10 +82,10 @@ interface EditorConfig { eol: number; } -let open = ref(false); -let loading = ref(false); +const open = ref(false); +const loading = ref(false); -let config = reactive({ +const config = reactive({ theme: 'vs-dark', language: 'plaintext', eol: monaco.editor.EndOfLineSequence.LF, @@ -129,7 +129,7 @@ const handleClose = () => { if (editor) { editor.dispose(); } - em('close', false); + em('close', open.value); }; const changeLanguage = () => { monaco.editor.setModelLanguage(editor.getModel(), config.language);