EventIndex: Bump our user version and delete the db if it's an old db.
This commit is contained in:
parent
9f9f24c624
commit
2aa00cbf41
2 changed files with 19 additions and 3 deletions
|
@ -42,9 +42,6 @@ export default class EventIndex extends EventEmitter {
|
||||||
async init() {
|
async init() {
|
||||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||||
|
|
||||||
await indexManager.initEventIndex();
|
|
||||||
console.log("EventIndex: Successfully initialized the event index");
|
|
||||||
|
|
||||||
this.crawlerCheckpoints = await indexManager.loadCheckpoints();
|
this.crawlerCheckpoints = await indexManager.loadCheckpoints();
|
||||||
console.log("EventIndex: Loaded checkpoints", this.crawlerCheckpoints);
|
console.log("EventIndex: Loaded checkpoints", this.crawlerCheckpoints);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ import PlatformPeg from "../PlatformPeg";
|
||||||
import EventIndex from "../indexing/EventIndex";
|
import EventIndex from "../indexing/EventIndex";
|
||||||
import SettingsStore, {SettingLevel} from '../settings/SettingsStore';
|
import SettingsStore, {SettingLevel} from '../settings/SettingsStore';
|
||||||
|
|
||||||
|
const INDEX_VERSION = 1;
|
||||||
|
|
||||||
class EventIndexPeg {
|
class EventIndexPeg {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.index = null;
|
this.index = null;
|
||||||
|
@ -66,8 +68,25 @@ class EventIndexPeg {
|
||||||
*/
|
*/
|
||||||
async initEventIndex() {
|
async initEventIndex() {
|
||||||
const index = new EventIndex();
|
const index = new EventIndex();
|
||||||
|
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
await indexManager.initEventIndex();
|
||||||
|
|
||||||
|
const userVersion = await indexManager.getUserVersion();
|
||||||
|
const eventIndexIsEmpty = await indexManager.isEventIndexEmpty();
|
||||||
|
|
||||||
|
if (eventIndexIsEmpty) {
|
||||||
|
await indexManager.setUserVersion(INDEX_VERSION);
|
||||||
|
} else if (userVersion === 0 && !eventIndexIsEmpty) {
|
||||||
|
await indexManager.closeEventIndex();
|
||||||
|
await this.deleteEventIndex();
|
||||||
|
|
||||||
|
await indexManager.initEventIndex();
|
||||||
|
await indexManager.setUserVersion(INDEX_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("EventIndex: Successfully initialized the event index");
|
||||||
await index.init();
|
await index.init();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("EventIndex: Error initializing the event index", e);
|
console.log("EventIndex: Error initializing the event index", e);
|
||||||
|
|
Loading…
Reference in a new issue