Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repair existing broken events in offline dbs
we have some cases of technically illegal events that got imported into some offline DBs. they were serialized in a lossy way and can be detected by checking for zeroed out start- and end times. this migration deletes the event lists from the offline db that contain such events, they will then be re-downloaded when the calendar is populated in the cache postlogin action. we're leaving events belonging to these lists in the cache, they will be overwritten while redownloading because of the use of INSERT OR REPLACE and the way we have set up our primary keys. #4660
- Loading branch information
Showing
5 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {OfflineMigration} from "../OfflineStorageMigrator.js" | ||
import {OfflineStorage} from "../OfflineStorage.js" | ||
import {CalendarEvent, CalendarEventTypeRef} from "../../../entities/tutanota/TypeRefs" | ||
import {getElementId, getListId} from "../../../common/utils/EntityUtils" | ||
|
||
export const repair1: OfflineMigration = { | ||
app: "repair", | ||
version: 1, | ||
async migrate(storage: OfflineStorage) { | ||
const allCalendarEvents: Array<CalendarEvent> = await storage.getListElementsOfType(CalendarEventTypeRef) | ||
const possiblyBrokenEvents = allCalendarEvents.filter(calendarEvent => calendarEvent.startTime.getTime() === 0 || calendarEvent.endTime.getTime() === 0) | ||
const brokenListIDs = new Set(possiblyBrokenEvents.map(getListId)) | ||
for (const listID of brokenListIDs) { | ||
await storage.deleteRange(CalendarEventTypeRef, listID) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters