{cmd,private,storagenode}: create storage dir verification during setup

Previously, we created a new file to use for directory verification
every time the storage node starts. This is not helpful if the storage node
points to the wrong directory when restarting. Now we will only create the file
on setup. Now the file should be created only once and will be verified at
runtime.

Change-Id: Id529f681469138d368e5ea3c63159befe62b1a5b
This commit is contained in:
Cameron Ayer 2020-11-06 13:45:58 -05:00
parent 4ce00c7caa
commit 5a337c48ec
3 changed files with 13 additions and 5 deletions

View File

@ -260,6 +260,15 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return err return err
} }
identity, err := setupCfg.Identity.Load()
if err != nil {
return err
}
if err := db.Pieces().CreateVerificationFile(identity.ID); err != nil {
return err
}
return db.Close() return db.Close()
} }

View File

@ -218,6 +218,10 @@ func (planet *Planet) newStorageNode(ctx context.Context, prefix string, index,
return nil, err return nil, err
} }
if err := db.Pieces().CreateVerificationFile(identity.ID); err != nil {
return nil, err
}
if planet.config.Reconfigure.StorageNodeDB != nil { if planet.config.Reconfigure.StorageNodeDB != nil {
db, err = planet.config.Reconfigure.StorageNodeDB(index, db, planet.log) db, err = planet.config.Reconfigure.StorageNodeDB(index, db, planet.log)
if err != nil { if err != nil {

View File

@ -113,11 +113,6 @@ func (service *Service) Run(ctx context.Context) (err error) {
return Error.New("disk space requirement not met") return Error.New("disk space requirement not met")
} }
// Create file to identify the storage directory.
if err := service.store.CreateVerificationFile(service.contact.Local().ID); err != nil {
return Error.New("failed to create storage directory verification: %v", err)
}
group, ctx := errgroup.WithContext(ctx) group, ctx := errgroup.WithContext(ctx)
group.Go(func() error { group.Go(func() error {
return service.VerifyDirReadableLoop.Run(ctx, func(ctx context.Context) error { return service.VerifyDirReadableLoop.Run(ctx, func(ctx context.Context) error {