From 7adbc6cffecbef1e6a4d05d359348b28fcbcee7b Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Sun, 8 Jan 2017 10:14:37 -0800 Subject: [PATCH] Add .json extension to log state filenames Since they are JSON. --- cmd/log_state.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/log_state.go b/cmd/log_state.go index a7df711..bf61567 100644 --- a/cmd/log_state.go +++ b/cmd/log_state.go @@ -38,7 +38,7 @@ func sthFilename (sth *ct.SignedTreeHead) string { panic(fmt.Sprintf("Unsupported STH version %d", sth.Version)) } // For 6962-bis, we will need to handle a variable-length root hash, and include the signature in the filename hash (since signatures must be deterministic) - return strconv.FormatUint(sth.TreeSize, 10) + "-" + base64.RawURLEncoding.EncodeToString(hasher.Sum(nil)) + return strconv.FormatUint(sth.TreeSize, 10) + "-" + base64.RawURLEncoding.EncodeToString(hasher.Sum(nil)) + ".json" } func makeLogStateDir (logStatePath string) error { @@ -62,7 +62,7 @@ func OpenLogState (logStatePath string) (*LogState, error) { } func (logState *LogState) VerifiedSTHFilename () string { - return filepath.Join(logState.path, "verified_sth") + return filepath.Join(logState.path, "verified_sth.json") } func (logState *LogState) GetVerifiedSTH () (*ct.SignedTreeHead, error) { @@ -130,7 +130,7 @@ func (logState *LogState) RemoveUnverifiedSTH (sth *ct.SignedTreeHead) error { func (logState *LogState) GetTree () (*certspotter.CollapsedMerkleTree, error) { tree := new(certspotter.CollapsedMerkleTree) - if err := readJSONFile(filepath.Join(logState.path, "tree"), tree); err != nil { + if err := readJSONFile(filepath.Join(logState.path, "tree.json"), tree); err != nil { if os.IsNotExist(err) { return nil, nil } else { @@ -141,5 +141,5 @@ func (logState *LogState) GetTree () (*certspotter.CollapsedMerkleTree, error) { } func (logState *LogState) StoreTree (tree *certspotter.CollapsedMerkleTree) error { - return writeJSONFile(filepath.Join(logState.path, "tree"), tree, 0666) + return writeJSONFile(filepath.Join(logState.path, "tree.json"), tree, 0666) }