mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
feat(ocis): allow skiping blobcheck in consistency command
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -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
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user