feat(ocis): allow skiping blobcheck in consistency command
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
+25
-17
@@ -23,9 +23,10 @@ type ListBlobstore interface {
|
|||||||
type DataProvider struct {
|
type DataProvider struct {
|
||||||
Events chan interface{}
|
Events chan interface{}
|
||||||
|
|
||||||
fsys fs.FS
|
fsys fs.FS
|
||||||
discpath string
|
discpath string
|
||||||
lbs ListBlobstore
|
lbs ListBlobstore
|
||||||
|
skipBlobs bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeData holds data about the nodes
|
// NodeData holds data about the nodes
|
||||||
@@ -52,9 +53,10 @@ func NewProvider(fsys fs.FS, discpath string, lbs ListBlobstore) *DataProvider {
|
|||||||
return &DataProvider{
|
return &DataProvider{
|
||||||
Events: make(chan interface{}),
|
Events: make(chan interface{}),
|
||||||
|
|
||||||
fsys: fsys,
|
fsys: fsys,
|
||||||
discpath: discpath,
|
discpath: discpath,
|
||||||
lbs: lbs,
|
lbs: lbs,
|
||||||
|
skipBlobs: lbs == nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,18 +91,20 @@ func (dp *DataProvider) ProduceData() error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// crawl blobstore
|
// crawl blobstore
|
||||||
wg.Add(1)
|
if !dp.skipBlobs {
|
||||||
go func() {
|
wg.Add(1)
|
||||||
bs, err := dp.lbs.List()
|
go func() {
|
||||||
if err != nil {
|
bs, err := dp.lbs.List()
|
||||||
fmt.Println("error listing blobs", err)
|
if err != nil {
|
||||||
}
|
fmt.Println("error listing blobs", err)
|
||||||
|
}
|
||||||
|
|
||||||
for _, bn := range bs {
|
for _, bn := range bs {
|
||||||
dp.Events <- BlobData{BlobPath: dp.lbs.Path(bn)}
|
dp.Events <- BlobData{BlobPath: dp.lbs.Path(bn)}
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// wait for all crawlers to finish
|
// wait for all crawlers to finish
|
||||||
go func() {
|
go func() {
|
||||||
@@ -112,6 +116,10 @@ func (dp *DataProvider) ProduceData() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dp *DataProvider) getBlobPath(path string) (string, Inconsistency) {
|
func (dp *DataProvider) getBlobPath(path string) (string, Inconsistency) {
|
||||||
|
if dp.skipBlobs {
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
b, err := fs.ReadFile(dp.fsys, path+".mpk")
|
b, err := fs.ReadFile(dp.fsys, path+".mpk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", InconsistencyFilesMissing
|
return "", InconsistencyFilesMissing
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func BackupCommand(cfg *config.Config) *cli.Command {
|
|||||||
ConsistencyCommand(cfg),
|
ConsistencyCommand(cfg),
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
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 {
|
Action: func(_ *cli.Context) error {
|
||||||
fmt.Println("Read the docs")
|
fmt.Println("Read the docs")
|
||||||
@@ -47,7 +47,7 @@ func ConsistencyCommand(cfg *config.Config) *cli.Command {
|
|||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "blobstore",
|
Name: "blobstore",
|
||||||
Aliases: []string{"b"},
|
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",
|
Value: "ocis",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -74,6 +74,8 @@ func ConsistencyCommand(cfg *config.Config) *cli.Command {
|
|||||||
)
|
)
|
||||||
case "ocis":
|
case "ocis":
|
||||||
bs, err = ocisbs.New(basePath)
|
bs, err = ocisbs.New(basePath)
|
||||||
|
case "none":
|
||||||
|
bs = nil
|
||||||
default:
|
default:
|
||||||
err = errors.New("blobstore type not supported")
|
err = errors.New("blobstore type not supported")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user