Quorum client creates its data folder before write 45/44745/2
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 25 Apr 2018 19:16:15 +0000 (12:16 -0700)
committerGirish Havaldar <hg0071052@techmahindra.com>
Thu, 26 Apr 2018 05:16:34 +0000 (05:16 +0000)
Data folder is not guaranteed to exist and therefore
needs to be created before writes can be done on it.

Issue-ID: AAF-261
Change-Id: I4671f0dac34a04c80639386719639b8c9472a9d3
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
sms-service/src/quorumclient/quorumclient.go

index dfa1a26..51dfc9c 100644 (file)
@@ -64,11 +64,14 @@ func loadPGPKeys(prKeyPath string, pbKeyPath string) (string, string, error) {
 //calls necessary initialization endpoints on the
 //SMS webservice
 func main() {
-       podName := os.Getenv("HOSTNAME")
-       idFilePath := filepath.Join("auth", podName, "id")
-       pbKeyPath := filepath.Join("auth", podName, "pbkey")
-       prKeyPath := filepath.Join("auth", podName, "prkey")
-       shardPath := filepath.Join("auth", podName, "shard")
+       folderName := os.Getenv("HOSTNAME")
+       //Make sure to create the folder. It is not guaranteed to exist
+       os.MkdirAll(folderName, 0700)
+
+       idFilePath := filepath.Join("auth", folderName, "id")
+       pbKeyPath := filepath.Join("auth", folderName, "pbkey")
+       prKeyPath := filepath.Join("auth", folderName, "prkey")
+       shardPath := filepath.Join("auth", folderName, "shard")
 
        smslogger.Init("quorum.log")
        smslogger.WriteInfo("Starting Log for Quorum Client")