aboutsummaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-20 01:08:12 -0400
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-20 01:08:12 -0400
commit6777286ba15d5bd05d0fcd9921049761bf2f59c0 (patch)
treebbb47bcda4f98ebbf0cfa9c49a21b1077ff675cf /pkg/api
parentf0051d99fd62a3776987bb25cf7f147022c2b93b (diff)
downloadAtlas-6777286ba15d5bd05d0fcd9921049761bf2f59c0.tar.gz
Atlas-6777286ba15d5bd05d0fcd9921049761bf2f59c0.zip
all: Make PdataStorage SetPdata return the stored pdata size
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/api0/accounts.go2
-rw-r--r--pkg/api/api0/api0testutil/storage.go8
-rw-r--r--pkg/api/api0/storage.go4
3 files changed, 7 insertions, 7 deletions
diff --git a/pkg/api/api0/accounts.go b/pkg/api/api0/accounts.go
index ed95ad1..c87530e 100644
--- a/pkg/api/api0/accounts.go
+++ b/pkg/api/api0/accounts.go
@@ -147,7 +147,7 @@ func (h *Handler) handleAccountsWritePersistence(w http.ResponseWriter, r *http.
}
}
- if err := h.PdataStorage.SetPdata(uid, buf); err != nil {
+ if _, err := h.PdataStorage.SetPdata(uid, buf); err != nil {
hlog.FromRequest(r).Error().
Err(err).
Uint64("uid", uid).
diff --git a/pkg/api/api0/api0testutil/storage.go b/pkg/api/api0/api0testutil/storage.go
index 80020fd..f6972a5 100644
--- a/pkg/api/api0/api0testutil/storage.go
+++ b/pkg/api/api0/api0testutil/storage.go
@@ -364,7 +364,7 @@ func TestPdataStorage(t *testing.T, s api0.PdataStorage) {
}
})
t.Run("PutUser1Pdata1", func(t *testing.T) {
- if err := s.SetPdata(user1, pdata1); err != nil {
+ if _, err := s.SetPdata(user1, pdata1); err != nil {
t.Fatalf("unexpected error: %v", err)
}
})
@@ -416,7 +416,7 @@ func TestPdataStorage(t *testing.T, s api0.PdataStorage) {
}
})
t.Run("PutUser1Pdata2", func(t *testing.T) {
- if err := s.SetPdata(user1, pdata2); err != nil {
+ if _, err := s.SetPdata(user1, pdata2); err != nil {
t.Fatalf("unexpected error: %v", err)
}
})
@@ -504,7 +504,7 @@ func TestPdataStorage(t *testing.T, s api0.PdataStorage) {
}
randSched()
- if err := s.SetPdata(uid, data1); err != nil {
+ if _, err := s.SetPdata(uid, data1); err != nil {
fail.Store(3)
return
}
@@ -528,7 +528,7 @@ func TestPdataStorage(t *testing.T, s api0.PdataStorage) {
}
randSched()
- if err := s.SetPdata(uid, data2); err != nil {
+ if _, err := s.SetPdata(uid, data2); err != nil {
fail.Store(7)
return
}
diff --git a/pkg/api/api0/storage.go b/pkg/api/api0/storage.go
index 3fe7378..a6de4cd 100644
--- a/pkg/api/api0/storage.go
+++ b/pkg/api/api0/storage.go
@@ -61,6 +61,6 @@ type PdataStorage interface {
// matches, buf is nil. If another error occurs, err is non-nil.
GetPdataCached(uid uint64, sha [sha256.Size]byte) (buf []byte, exists bool, err error)
- // SetPdata sets the raw pdata for uid.
- SetPdata(uid uint64, buf []byte) (err error)
+ // SetPdata sets the raw pdata for uid, returning the actual size stored.
+ SetPdata(uid uint64, buf []byte) (n int, err error)
}