[ISSUE-69568832] address comments
diff --git a/api.go b/api.go index 62e370c..1fceebb 100644 --- a/api.go +++ b/api.go
@@ -25,8 +25,11 @@ const tokenEndpoint = "/accesstoken" const ( + // long-polling timeout from http header parBlock = "block" - parTag = "If-None-Match" + // long-polling tag used for comparision + // if tag fails to match, new token is returned immediately + parTag = "If-None-Match" ) type ApiManager struct {
diff --git a/snapshot.go b/snapshot.go index c18b1c8..023314d 100644 --- a/snapshot.go +++ b/snapshot.go
@@ -30,6 +30,7 @@ ) const bootstrapSnapshotName = "bootstrap" +const lengthSqliteFileName = 7 // len("/sqlite") const ( headerSnapshotNumber = "Transicator-Snapshot-TXID" ) @@ -220,14 +221,16 @@ func processSnapshotServerFileResponse(dbId string, body io.Reader, snapshot *common.Snapshot) error { dbPath := data.DBPath("common/" + dbId) - dbDir := dbPath[0 : len(dbPath)-7] + dbDir := dbPath[0 : len(dbPath)-lengthSqliteFileName] log.Infof("Attempting to stream the sqlite snapshot to %s", dbPath) - // if exists, delete the old snapshot file - if _, err := os.Stat(dbDir); !os.IsNotExist(err) { - if err = os.RemoveAll(dbDir); err != nil { - log.Errorf("Failed to delete old snapshot; %v", err) - return err + // if other bootstrap snapshot exists, delete the old file + if dbId == bootstrapSnapshotName { + if _, err := os.Stat(dbDir); !os.IsNotExist(err) { + if err = os.RemoveAll(dbDir); err != nil { + log.Errorf("Failed to delete old bootstrap snapshot; %v", err) + return err + } } }