Skip to content

Commit

Permalink
feat(ocis): allow skiping blobcheck in consistency command
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Jun 11, 2024
1 parent 222ead4 commit 9a84284
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
42 changes: 25 additions & 17 deletions ocis/pkg/backup/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ type ListBlobstore interface {
type DataProvider struct {
Events chan interface{}

fsys fs.FS
discpath string
lbs ListBlobstore
fsys fs.FS
discpath string
lbs ListBlobstore
skipBlobs bool
}

// NodeData holds data about the nodes
Expand All @@ -52,9 +53,10 @@ func NewProvider(fsys fs.FS, discpath string, lbs ListBlobstore) *DataProvider {
return &DataProvider{
Events: make(chan interface{}),

fsys: fsys,
discpath: discpath,
lbs: lbs,
fsys: fsys,
discpath: discpath,
lbs: lbs,
skipBlobs: lbs == nil,
}
}

Expand Down Expand Up @@ -89,18 +91,20 @@ func (dp *DataProvider) ProduceData() error {
}()

// crawl blobstore
wg.Add(1)
go func() {
bs, err := dp.lbs.List()
if err != nil {
fmt.Println("error listing blobs", err)
}
if !dp.skipBlobs {
wg.Add(1)
go func() {
bs, err := dp.lbs.List()
if err != nil {
fmt.Println("error listing blobs", err)
}

for _, bn := range bs {
dp.Events <- BlobData{BlobPath: dp.lbs.Path(bn)}
}
wg.Done()
}()
for _, bn := range bs {
dp.Events <- BlobData{BlobPath: dp.lbs.Path(bn)}
}
wg.Done()
}()
}

// wait for all crawlers to finish
go func() {
Expand All @@ -112,6 +116,10 @@ func (dp *DataProvider) ProduceData() error {
}

func (dp *DataProvider) getBlobPath(path string) (string, Inconsistency) {
if dp.skipBlobs {
return "", ""
}

b, err := fs.ReadFile(dp.fsys, path+".mpk")
if err != nil {
return "", InconsistencyFilesMissing
Expand Down
6 changes: 4 additions & 2 deletions ocis/pkg/command/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func BackupCommand(cfg *config.Config) *cli.Command {
ConsistencyCommand(cfg),
},
Before: func(c *cli.Context) error {
return configlog.ReturnError(parser.ParseConfig(cfg, false))
return configlog.ReturnError(parser.ParseConfig(cfg, true))
},
Action: func(_ *cli.Context) error {
fmt.Println("Read the docs")
Expand All @@ -47,7 +47,7 @@ func ConsistencyCommand(cfg *config.Config) *cli.Command {
&cli.StringFlag{
Name: "blobstore",
Aliases: []string{"b"},
Usage: "the blobstore type. Can be (ocis, s3ng). Default ocis",
Usage: "the blobstore type. Can be (none, ocis, s3ng). Default ocis",
Value: "ocis",
},
},
Expand All @@ -74,6 +74,8 @@ func ConsistencyCommand(cfg *config.Config) *cli.Command {
)
case "ocis":
bs, err = ocisbs.New(basePath)
case "none":
bs = nil
default:
err = errors.New("blobstore type not supported")
}
Expand Down

0 comments on commit 9a84284

Please sign in to comment.