mirror of
https://github.com/samuelncui/yatm.git
synced 2026-09-26 01:44:51 +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) {
|
||||
|
||||
Reference in New Issue
Block a user