Skip to content

Commit

Permalink
fix chain suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
fraidev committed Nov 21, 2023
1 parent 3e91456 commit 35837e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 5 additions & 0 deletions pkg/snapshot/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package snapshot

import (
"encoding/json"
"strings"
)

type SnapshotHeader struct {
Expand All @@ -26,3 +27,7 @@ func SnapshotHeaderFromJson(snapshotHeaderOutput string) (*SnapshotHeader, error

return &snapshotHeader.SnapshotHeader, nil
}

func (s *SnapshotHeader) SanitizeChainName() string {
return strings.ToLower(strings.Split(strings.Split(s.ChaiName, "-")[0], "_")[1])
}
9 changes: 1 addition & 8 deletions pkg/store/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (s *SnapshotStorage) GetSnapshotItems(ctx context.Context) []snapshot.Snaps
Filename: filename,
Filesize: util.FileSize(size),
FilesizeBytes: size,
ChainName: RemoveTezosPrefix(snapshotHeader.ChaiName),
ChainName: snapshotHeader.SanitizeChainName(),
Date: date,
BlockTimestamp: snapshotHeader.Timestamp,
URL: obj.MediaLink,
Expand Down Expand Up @@ -169,13 +169,6 @@ func (s *SnapshotStorage) GetSnapshotItems(ctx context.Context) []snapshot.Snaps
return items
}

func RemoveTezosPrefix(filename string) string {
if strings.HasPrefix(filename, "TEZOS_") {
return strings.ToLower(filename[6:])
}
return filename
}

func (s *SnapshotStorage) DeleteExpiredSnapshots(ctx context.Context, maxDays int, maxMonths int) {
log.Println("Deleting expired snapshots in the Google Cloud Storage.")

Expand Down

0 comments on commit 35837e0

Please sign in to comment.