You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Collections] Trigger collection refresh if deserialization of SQLite data fails (#3305)
Motivation:
When package collection model/format changes, deserializing data stored in SQLite might fail. Most of the time `SQLitePackageCollectionsStorage`
just silently ignores deserialization errors, and no one would know that something had gone wrong. This could lead to collection APIs not
returning any data, which would be confusing for users.
What we should do with this kind of deserialization error is to trigger collection refresh so that data in SQLite gets updated. `listCollections`
can do this quite easily by calling refresh whenever the results count does not equal sources count.
Modifications:
In `listCollections` check that sources count equals results count, otherwise trigger refresh on the "missing" collections.
Copy file name to clipboardExpand all lines: Tests/PackageCollectionsTests/PackageCollectionsTests.swift
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,7 @@ final class PackageCollectionsTests: XCTestCase {
98
98
}
99
99
// User preference unknown
100
100
XCTAssertThrowsError(
101
-
trytsc_await{ callback in packageCollections.addCollection(mockCollections[1].source, order:nil, trustConfirmationProvider:nil, callback: callback)}){ error in
101
+
trytsc_await{ callback in packageCollections.addCollection(mockCollections[2].source, order:nil, trustConfirmationProvider:nil, callback: callback)}){ error in
102
102
guard case PackageCollectionError.trustConfirmationRequired = error else{
0 commit comments