Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func apiSnapshotsList(c *gin.Context) {
err := collection.ForEachSorted(SortMethodString, func(snapshot *deb.Snapshot) error {
err := collection.LoadComplete(snapshot)
if err != nil {
if err == database.ErrNotFound {
return nil
}
return err
}

Expand Down
13 changes: 13 additions & 0 deletions api/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,16 @@ func (s *SnapshotsSuite) TestGetSnapshotsReturns500OnCorruptRefList(c *C) {
c.Assert(response.Code, Equals, 500)
c.Assert(response.Body.String(), Matches, ".*msgpack.*|.*decode.*")
}

func (s *SnapshotsSuite) TestGetSnapshotsHandlesConcurrentDeletion(c *C) {
collection := s.context.NewCollectionFactory().SnapshotCollection()
snapshot := deb.NewSnapshotFromRefList("deleted-snapshot-list", nil, makePackageRefList(c), "")
c.Assert(collection.Add(snapshot), IsNil)
// Simulate concurrent deletion by dropping the ref key or entire snapshot record
c.Assert(collection.Drop(snapshot), IsNil)

response, err := s.HTTPRequest("GET", "/api/snapshots", nil)
c.Assert(err, IsNil)
c.Assert(response.Code, Equals, 200)
}

Loading