mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: optimized code
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user