🎨 Improve file copy

This commit is contained in:
Daniel 2023-06-15 09:41:42 +08:00
parent d12b39c3c2
commit e93c62e49f
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
4 changed files with 13 additions and 7 deletions

View File

@ -48,7 +48,7 @@ require (
github.com/siyuan-note/dejavu v0.0.0-20230612120039-bba808ca7649
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b
github.com/siyuan-note/filelock v0.0.0-20230523004741-d9121740f638
github.com/siyuan-note/filelock v0.0.0-20230615011542-df9ae6b3f981
github.com/siyuan-note/httpclient v0.0.0-20230610031552-11458e2e39b0
github.com/siyuan-note/logging v0.0.0-20230327073243-ebe83aec1493
github.com/siyuan-note/riff v0.0.0-20230516073320-b440b8feaabd
@ -59,7 +59,7 @@ require (
golang.org/x/image v0.7.0
golang.org/x/mobile v0.0.0-20230531173138-3c911d8e3eda
golang.org/x/mod v0.10.0
golang.org/x/text v0.9.0
golang.org/x/text v0.10.0
)
require (
@ -132,7 +132,7 @@ require (
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/tools v0.9.3 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect

View File

@ -289,6 +289,8 @@ github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b h1:828lTUW2C0
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
github.com/siyuan-note/filelock v0.0.0-20230523004741-d9121740f638 h1:0dvT+1FvuUf6/GFkFRQML0Q3DLulbswj1GJJ0j7BlD8=
github.com/siyuan-note/filelock v0.0.0-20230523004741-d9121740f638/go.mod h1:v2bpUtjvsvt1TRHgly1mIXQjAEo/t50dOM9YiC813qQ=
github.com/siyuan-note/filelock v0.0.0-20230615011542-df9ae6b3f981 h1:ulmzDD3Z3tsJAIec9sLLGuK88tuuE2o9Ux8Vog8KQBc=
github.com/siyuan-note/filelock v0.0.0-20230615011542-df9ae6b3f981/go.mod h1:jK5lCYfPbFOrW23/HMeU7kmpLdEd5GkennF+kUpy7Vs=
github.com/siyuan-note/httpclient v0.0.0-20230610031552-11458e2e39b0 h1:RKdpy6P1LjUBgQ/7hKO+UmcSwfWzcpMAKRh/deNiVXQ=
github.com/siyuan-note/httpclient v0.0.0-20230610031552-11458e2e39b0/go.mod h1:wqRaWZoA/NZJzZ6aCszp75Bi6dH7ZVcb8JWRysvrC2Y=
github.com/siyuan-note/logging v0.0.0-20230327073243-ebe83aec1493 h1:oaN5b0WDFkjdBgGxmmBnMrtZxaJ76LZLwhQSZnznJMI=
@ -411,6 +413,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -428,6 +432,8 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

View File

@ -257,7 +257,7 @@ func ExportDataInFolder(exportFolder string) (name string, err error) {
name = filepath.Base(zipPath)
targetZipPath := filepath.Join(exportFolder, name)
zipAbsPath := filepath.Join(util.TempDir, "export", name)
err = filelock.RoboCopy(zipAbsPath, targetZipPath)
err = filelock.Copy(zipAbsPath, targetZipPath)
if nil != err {
logging.LogErrorf("copy export zip from [%s] to [%s] failed: %s", zipAbsPath, targetZipPath, err)
return
@ -291,7 +291,7 @@ func exportData(exportFolder string) (zipPath string, err error) {
}
data := filepath.Join(util.WorkspaceDir, "data")
if err = filelock.RoboCopy(data, exportFolder); nil != err {
if err = filelock.Copy(data, exportFolder); nil != err {
logging.LogErrorf("copy data dir from [%s] to [%s] failed: %s", data, baseFolderName, err)
err = errors.New(fmt.Sprintf(Conf.Language(14), err.Error()))
return

View File

@ -383,7 +383,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
return nil
})
if err = filelock.RoboCopy(unzipRootPath, targetDir); nil != err {
if err = filelock.Copy(unzipRootPath, targetDir); nil != err {
logging.LogErrorf("copy data dir from [%s] to [%s] failed: %s", unzipRootPath, util.DataDir, err)
err = errors.New("copy data failed")
return
@ -440,7 +440,7 @@ func ImportData(zipPath string) (err error) {
}
tmpDataPath := filepath.Join(unzipPath, dirs[0].Name())
if err = filelock.RoboCopy(tmpDataPath, util.DataDir); nil != err {
if err = filelock.Copy(tmpDataPath, util.DataDir); nil != err {
logging.LogErrorf("copy data dir from [%s] to [%s] failed: %s", tmpDataPath, util.DataDir, err)
err = errors.New("copy data failed")
return