MCPcopy Index your code
hub / github.com/4ian/GDevelop / _initializeDatabase

Method _initializeDatabase

newIDE/app/src/Utils/ProjectCache.js:111–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109 }
110
111 _initializeDatabase(): any {
112 if (!this.databasePromise) {
113 this.databasePromise = new Promise<IDBDatabase>((resolve, reject) => {
114 ProjectCache._removeDatabaseIfCorrupt().then(
115 () => {
116 const request = window.indexedDB.open(
117 CLOUD_PROJECT_AUTOSAVE_CACHE_KEY
118 );
119 request.onsuccess = event => {
120 const db = event.target.result;
121 if (!db.objectStoreNames.contains(objectStoreScope)) {
122 // The onUpgradeNeeded is called before the success event so the object
123 // store should exist.
124 console.error(
125 `Couldn't find the object store ${objectStoreScope}. An issue must have happened when creating the database.`
126 );
127 }
128 resolve(db);
129 };
130 request.onerror = event => {
131 console.error('IndexedDB could not be opened:', event);
132 reject(event);
133 };
134 request.onupgradeneeded = event => {
135 const db = event.target.result;
136
137 if (!db.objectStoreNames.contains(objectStoreScope)) {
138 db.createObjectStore(objectStoreScope, { keyPath: keyName });
139 }
140 };
141 },
142 error => {
143 console.error(
144 'An error occurred while clearing a corrupt database.',
145 error
146 );
147 }
148 );
149 });
150 }
151 return this.databasePromise;
152 }
153
154 async _getEntry(cacheKey: ProjectCacheKey): any {
155 const database = await this._initializeDatabase();

Callers 2

_getEntryMethod · 0.95
putMethod · 0.95

Calls 7

resolveFunction · 0.85
createObjectStoreMethod · 0.80
thenMethod · 0.65
openMethod · 0.65
errorMethod · 0.65
containsMethod · 0.45

Tested by

no test coverage detected