From 57eb8a17e2666d0062f70f283ccb3e754917b7f5 Mon Sep 17 00:00:00 2001 From: Jeff Wendling Date: Thu, 30 Apr 2020 16:08:32 -0600 Subject: [PATCH] storagenode: allow configuring database path independently Fixes #3852 Change-Id: I021c29c4dd7c393399f6abef41d8457514032833 --- storagenode/peer.go | 8 ++++++-- storagenode/piecestore/endpoint.go | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/storagenode/peer.go b/storagenode/peer.go index 4d8ed544c..28beeb892 100644 --- a/storagenode/peer.go +++ b/storagenode/peer.go @@ -125,10 +125,14 @@ type Config struct { // DatabaseConfig returns the storagenodedb.Config that should be used with this Config. func (config *Config) DatabaseConfig() storagenodedb.Config { + dbdir := config.Storage2.DatabaseDir + if dbdir == "" { + dbdir = config.Storage.Path + } return storagenodedb.Config{ Storage: config.Storage.Path, - Info: filepath.Join(config.Storage.Path, "piecestore.db"), - Info2: filepath.Join(config.Storage.Path, "info.db"), + Info: filepath.Join(dbdir, "piecestore.db"), + Info2: filepath.Join(dbdir, "info.db"), Pieces: config.Storage.Path, Filestore: config.Filestore, } diff --git a/storagenode/piecestore/endpoint.go b/storagenode/piecestore/endpoint.go index 7e7ffd889..2be97b05c 100644 --- a/storagenode/piecestore/endpoint.go +++ b/storagenode/piecestore/endpoint.go @@ -53,6 +53,7 @@ type OldConfig struct { // Config defines parameters for piecestore endpoint. type Config struct { + DatabaseDir string `help:"directory to store databases. if empty, uses data path" default:""` ExpirationGracePeriod time.Duration `help:"how soon before expiration date should things be considered expired" default:"48h0m0s"` MaxConcurrentRequests int `help:"how many concurrent requests are allowed, before uploads are rejected. 0 represents unlimited." default:"0"` DeleteWorkers int `help:"how many piece delete workers" default:"0"`