From 6f1dd2970e6538d8a96a93d8065fee269513c507 Mon Sep 17 00:00:00 2001 From: robinbryce Date: Tue, 28 May 2024 10:06:50 +0100 Subject: [PATCH] fix: the watcher incorrectly parsed massif numbers (#15) It parsed them from the blob path as hex. They are simple decimal counters. AB#9541 Co-authored-by: Robin Bryce --- massifs/pathparse.go | 2 +- massifs/pathparse_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/massifs/pathparse.go b/massifs/pathparse.go index da220eb..deac816 100644 --- a/massifs/pathparse.go +++ b/massifs/pathparse.go @@ -71,7 +71,7 @@ func ParseMassifPathNumberExt(path string) (uint32, string, error) { if parts[1] != V1MMRMassifExt && parts[1] != V1MMRSealSignedRootExt { return 0, "", fmt.Errorf("%w: extension invalid %s", ErrMassifPathFmt, path) } - number, err := strconv.ParseUint(parts[0], 16, 32) + number, err := strconv.ParseUint(parts[0], 10, 32) if err != nil { return 0, "", fmt.Errorf("%w: log file number invalid %s (%v)", ErrMassifPathFmt, path, err) } diff --git a/massifs/pathparse_test.go b/massifs/pathparse_test.go index 2584805..6e5e4bb 100644 --- a/massifs/pathparse_test.go +++ b/massifs/pathparse_test.go @@ -58,7 +58,13 @@ func TestParseMassifPathNumberExt(t *testing.T) { want1 string wantErr bool }{ - // TODO: Add test cases. + { + "decimal / hex confusion", + args{"v1/mmrs/tenant/84e0e9e9-d479-4d4e-9e8c-afc19a8fc185/0/massifs/0000000000000051.log"}, + 51, + "log", + false, + }, { "happy case", args{"v1/mmrs/tenant/84e0e9e9-d479-4d4e-9e8c-afc19a8fc185/0/massifs/0000000000000002.log"},