feat: optimized code

This commit is contained in:
Marvin Zhang
2024-06-17 23:31:34 +08:00
parent 3727ea6970
commit 41e7edf9f9
6 changed files with 364 additions and 243 deletions

View File

@@ -4,6 +4,8 @@ import (
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/utils"
"github.com/crawlab-team/crawlab/trace"
"github.com/google/uuid"
"io"
"os"
"path/filepath"
@@ -159,6 +161,15 @@ func (svc *ServiceV2) Copy(path, newPath string) (err error) {
}
}
func (svc *ServiceV2) Export() (resultPath string, err error) {
zipFilePath := filepath.Join(os.TempDir(), uuid.New().String()+".zip")
if err := utils.ZipDirectory(svc.rootPath, zipFilePath); err != nil {
return "", trace.TraceError(err)
}
return zipFilePath, nil
}
func NewFsServiceV2(path string) (svc interfaces.FsServiceV2) {
return &ServiceV2{
rootPath: path,