fix: check report bug
This commit is contained in:
parent
ed63ededf1
commit
ecc3d7fa64
|
@ -122,11 +122,11 @@ var Check = &cobra.Command{
|
|||
}
|
||||
}
|
||||
|
||||
if countNotInCloud > 0 {
|
||||
if countNotInLocal > 0 {
|
||||
reportBuilder.WriteString("\n")
|
||||
reportBuilder.WriteString(cloudBuilder.String())
|
||||
}
|
||||
if countNotInLocal > 0 {
|
||||
if countNotInCloud > 0 {
|
||||
reportBuilder.WriteString("\n")
|
||||
reportBuilder.WriteString(localBuilder.String())
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
|
@ -56,8 +57,10 @@ func (b *BackBlaze) b2BucketFiles(ctx context.Context, bucketName string, fileCh
|
|||
if bucketIter.Object() == nil {
|
||||
return errors.New("bucketIter Object is nil")
|
||||
}
|
||||
b.logger.Debug("bucket file: ", bucketIter.Object().Name())
|
||||
fileChan <- bucketIter.Object().Name()
|
||||
|
||||
// Retrieve just filename
|
||||
b.logger.Debugln("bucket file: ", path.Base(bucketIter.Object().Name()))
|
||||
fileChan <- path.Base(bucketIter.Object().Name())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -93,7 +96,7 @@ func (b *BackBlaze) CompareConcurrent(ctx context.Context, backupDir, bucketName
|
|||
if _, ok := localFiles[f]; ok {
|
||||
panic(fmt.Errorf("local file already exists in map: %s", f))
|
||||
}
|
||||
b.logger.Debug("local file ", f)
|
||||
b.logger.Debugln("local file ", f)
|
||||
localFiles[f]++
|
||||
}
|
||||
}()
|
||||
|
@ -114,7 +117,7 @@ func (b *BackBlaze) CompareConcurrent(ctx context.Context, backupDir, bucketName
|
|||
if _, ok := cloudFiles[f]; ok {
|
||||
panic(fmt.Errorf("cloud file already exists in map: %s", f))
|
||||
}
|
||||
b.logger.Debug("B2 file ", f)
|
||||
b.logger.Debugln("B2 file ", f)
|
||||
cloudFiles[f]++
|
||||
}
|
||||
}()
|
||||
|
@ -143,6 +146,7 @@ func (b *BackBlaze) CompareConcurrent(ctx context.Context, backupDir, bucketName
|
|||
go func() {
|
||||
defer wg.Done()
|
||||
for cloudFile := range cloudFiles {
|
||||
b.logger.Debugln("cloudFile ", cloudFile)
|
||||
if _, exists := localFiles[cloudFile]; !exists {
|
||||
msgChan <- B2Local{File: cloudFile, Err: ErrCloudNotInLocal}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func (b *BackBlaze) CleanUp(ctx context.Context, cancel context.CancelFunc, buck
|
|||
smpl.Set("account", b.bbID)
|
||||
smpl.Set("key", b.bbKey)
|
||||
smpl.Set("chunk_size", strconv.FormatInt(int64(9600), 10))
|
||||
b.logger.Info("duplicates", len(dups))
|
||||
b.logger.Infoln("duplicates", len(dups))
|
||||
for _, d := range dups {
|
||||
f, err := b2.NewFs(ctx, "B2", d.dir(), smpl)
|
||||
if err != nil {
|
||||
|
@ -43,7 +43,7 @@ func (b *BackBlaze) CleanUp(ctx context.Context, cancel context.CancelFunc, buck
|
|||
if err := operations.CleanUp(ctx, f); err != nil {
|
||||
return fmt.Errorf("operations.CleanUp %w", err)
|
||||
}
|
||||
b.logger.Info(d.dir(), "cleaned up")
|
||||
b.logger.Infoln(d.dir(), "cleaned up")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -72,20 +72,20 @@ func (b *BackBlaze) listDuplicates(ctx context.Context, cancel context.CancelFun
|
|||
|
||||
bucketIter := bc.List(ctx, b2.ListHidden())
|
||||
if bucketIter == nil {
|
||||
b.logger.Error("bucket list cannot be nil")
|
||||
b.logger.Errorln("bucket list cannot be nil")
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
if !bucketIter.Next() {
|
||||
if bucketIter.Err() != nil {
|
||||
b.logger.Error("bucketIter err %w", bucketIter.Err())
|
||||
b.logger.Errorf("bucketIter err %s", bucketIter.Err())
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
if bucketIter.Object() == nil {
|
||||
b.logger.Error("bucketIter Object is nil")
|
||||
b.logger.Errorln("bucketIter Object is nil")
|
||||
continue
|
||||
}
|
||||
files[bucketIter.Object().Name()]++
|
||||
|
|
|
@ -50,9 +50,9 @@ func (b *BackBlaze) Sync(ctx context.Context) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("bucketFiles %w", err)
|
||||
}
|
||||
b.logger.Debug(strings.Repeat("*", 40))
|
||||
b.logger.Debug("oldFiles to clean:\n\t\t" + strings.Join(oldFiles, "\n\t\t"))
|
||||
b.logger.Debug(strings.Repeat("*", 40))
|
||||
b.logger.Debugln(strings.Repeat("*", 40))
|
||||
b.logger.Debugln("oldFiles to clean:\n\t\t" + strings.Join(oldFiles, "\n\t\t"))
|
||||
b.logger.Debugln(strings.Repeat("*", 40))
|
||||
|
||||
fileChan := make(chan string)
|
||||
|
||||
|
@ -95,7 +95,7 @@ func (b *BackBlaze) Sync(ctx context.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
b.logger.Info("copied successfully")
|
||||
b.logger.Infoln("copied successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ func (b *BackBlaze) copyFile(ctx context.Context, bucket *b2.Bucket, src string)
|
|||
w := bucket.Object(fi.Name()).NewWriter(ctx)
|
||||
w.ConcurrentUploads = writers
|
||||
w.UseFileBuffer = true
|
||||
b.logger.Info("start copying", fi.Name())
|
||||
b.logger.Infoln("start copying ", fi.Name())
|
||||
if _, err := io.Copy(w, f); err != nil {
|
||||
w.Close()
|
||||
return err
|
||||
|
@ -121,7 +121,7 @@ func (b *BackBlaze) copyFile(ctx context.Context, bucket *b2.Bucket, src string)
|
|||
return err
|
||||
}
|
||||
|
||||
b.logger.Info("end copying", fi.Name())
|
||||
b.logger.Infoln("end copying ", fi.Name())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ func (b *BackBlaze) cleanBucket(ctx context.Context, bucket *b2.Bucket, files []
|
|||
for _, v := range files {
|
||||
obj := bucket.Object(v)
|
||||
if obj == nil {
|
||||
b.logger.Error("bucket.Object is nil", v)
|
||||
b.logger.Errorln("bucket.Object is nil", v)
|
||||
continue
|
||||
}
|
||||
if err := obj.Delete(ctx); err != nil {
|
||||
|
@ -160,7 +160,7 @@ func (b *BackBlaze) bucketFiles(ctx context.Context, bucket *b2.Bucket) ([]strin
|
|||
break
|
||||
}
|
||||
if bucketIter.Object() == nil {
|
||||
b.logger.Error("bucketIter Object is nil")
|
||||
b.logger.Errorln("bucketIter Object is nil")
|
||||
continue
|
||||
}
|
||||
files = append(files, bucketIter.Object().Name())
|
||||
|
|
Loading…
Reference in New Issue