mirror of
https://github.com/samuelncui/yatm.git
synced 2026-01-05 04:55:23 +00:00
fix: event callback
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
mapset "github.com/deckarep/golang-set/v2"
|
||||
"github.com/samber/lo"
|
||||
"github.com/samuelncui/acp"
|
||||
"github.com/samuelncui/tapewriter/entity"
|
||||
"github.com/samuelncui/tapewriter/library"
|
||||
@@ -230,6 +231,12 @@ func (a *jobArchiveExecutor) makeTape(ctx context.Context, device, barcode, name
|
||||
idx := sort.Search(len(a.state.Sources), func(idx int) bool {
|
||||
return src.Compare(a.state.Sources[idx].Source) <= 0
|
||||
})
|
||||
if idx < 0 {
|
||||
a.logger.Warnf(
|
||||
"cannot found target file, real_path= %s tape_file_path= %v", src.RealPath(),
|
||||
lo.Map(a.state.Sources, func(source *entity.SourceState, _ int) string { return source.Source.RealPath() }))
|
||||
return
|
||||
}
|
||||
|
||||
target := a.state.Sources[idx]
|
||||
if target == nil || !src.Equal(target.Source) {
|
||||
|
||||
@@ -90,6 +90,7 @@ func (a *jobRestoreExecutor) handle(ctx context.Context, param *entity.JobRestor
|
||||
tools.Working()
|
||||
go tools.WrapWithLogger(ctx, a.logger, func() {
|
||||
defer tools.Done()
|
||||
|
||||
if err := a.restoreTape(tools.ShutdownContext, p.Device); err != nil {
|
||||
a.logger.WithContext(ctx).WithError(err).Errorf("restore tape has error, device= '%s'", p.Device)
|
||||
}
|
||||
@@ -207,7 +208,7 @@ func (a *jobRestoreExecutor) restoreTape(ctx context.Context, device string) (re
|
||||
}
|
||||
}()
|
||||
|
||||
opts := make([]acp.Option, 0, 4)
|
||||
opts := make([]acp.Option, 0, 16)
|
||||
for _, f := range restoreTape.Files {
|
||||
if f.Status == entity.CopyStatus_SUBMITED {
|
||||
continue
|
||||
@@ -272,6 +273,12 @@ func (a *jobRestoreExecutor) restoreTape(ctx context.Context, device string) (re
|
||||
idx := sort.Search(len(restoreTape.Files), func(idx int) bool {
|
||||
return convertPath(realPath) < convertPath(sourcePath(restoreTape.Files[idx].TapePath))
|
||||
})
|
||||
if idx < 0 {
|
||||
a.logger.Warnf(
|
||||
"cannot found target file, real_path= %s tape_file_path= %v", realPath,
|
||||
lo.Map(restoreTape.Files, func(file *entity.RestoreFile, _ int) string { return sourcePath(file.TapePath) }))
|
||||
return
|
||||
}
|
||||
|
||||
target := restoreTape.Files[idx]
|
||||
if target == nil || realPath != sourcePath(target.TapePath) {
|
||||
|
||||
2
go.mod
2
go.mod
@@ -19,7 +19,7 @@ require (
|
||||
github.com/modern-go/reflect2 v1.0.2
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/samber/lo v1.38.1
|
||||
github.com/samuelncui/acp v0.0.0-20230922055057-290748251e42
|
||||
github.com/samuelncui/acp v0.0.0-20230922125743-18086b0be766
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
google.golang.org/grpc v1.53.0
|
||||
google.golang.org/protobuf v1.30.0
|
||||
|
||||
4
go.sum
4
go.sum
@@ -363,8 +363,8 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
|
||||
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
|
||||
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/samuelncui/acp v0.0.0-20230922055057-290748251e42 h1:FnVk2nAOBOy8la+J7le1zcZa5kI39fyWDMt30pB97lQ=
|
||||
github.com/samuelncui/acp v0.0.0-20230922055057-290748251e42/go.mod h1:cy5nMv6EZMvC4K3u1vLdLWFGHVWeRRoOUNw0kk+Wtvo=
|
||||
github.com/samuelncui/acp v0.0.0-20230922125743-18086b0be766 h1:oCViy9iD4DlfXIFuKON2VMsWN9dwuQ9w1CKvu1EVQWg=
|
||||
github.com/samuelncui/acp v0.0.0-20230922125743-18086b0be766/go.mod h1:cy5nMv6EZMvC4K3u1vLdLWFGHVWeRRoOUNw0kk+Wtvo=
|
||||
github.com/schollz/progressbar/v3 v3.12.2 h1:yLqqqpQNMxGxHY8uEshRihaHWwa0rf0yb7/Zrpgq2C0=
|
||||
github.com/schollz/progressbar/v3 v3.12.2/go.mod h1:HFJYIYQQJX32UJdyoigUl19xoV6aMwZt6iX/C30RWfg=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
|
||||
Reference in New Issue
Block a user