parent
3d512bf5c4
commit
9b620ba18a
@ -294,19 +294,24 @@ angular.module('izhukov.utils', [])
|
||||
return openDbPromise;
|
||||
}
|
||||
|
||||
try {
|
||||
var request = indexedDB.open(dbName, dbVersion),
|
||||
deferred = $q.defer(),
|
||||
createObjectStore = function (db) {
|
||||
db.createObjectStore(dbStoreName);
|
||||
};
|
||||
} catch (error) {
|
||||
storageIsAvailable = false;
|
||||
return $q.reject(error);
|
||||
}
|
||||
|
||||
request.onsuccess = function (event) {
|
||||
db = request.result;
|
||||
|
||||
db.onerror = function (event) {
|
||||
db.onerror = function (error) {
|
||||
storageIsAvailable = false;
|
||||
console.error("Error creating/accessing IndexedDB database", event);
|
||||
deferred.reject(event);
|
||||
console.error('Error creating/accessing IndexedDB database', error);
|
||||
deferred.reject(error);
|
||||
};
|
||||
|
||||
// Interim solution for Google Chrome to create an objectStore. Will be deprecated
|
||||
@ -326,6 +331,12 @@ angular.module('izhukov.utils', [])
|
||||
}
|
||||
};
|
||||
|
||||
request.onerror = function (event) {
|
||||
storageIsAvailable = false;
|
||||
console.error('Error creating/accessing IndexedDB database', event);
|
||||
deferred.reject(event);
|
||||
}
|
||||
|
||||
request.onupgradeneeded = function (event) {
|
||||
createObjectStore(event.target.result);
|
||||
};
|
||||
@ -385,6 +396,8 @@ angular.module('izhukov.utils', [])
|
||||
return $q.when(fakeWriter);
|
||||
}
|
||||
|
||||
openDatabase();
|
||||
|
||||
return {
|
||||
isAvailable: isAvailable,
|
||||
saveFile: saveFile,
|
||||
@ -481,6 +494,8 @@ angular.module('izhukov.utils', [])
|
||||
})
|
||||
}
|
||||
|
||||
requestFS();
|
||||
|
||||
return {
|
||||
isAvailable: isAvailable,
|
||||
saveFile: saveFile,
|
||||
|
Loading…
Reference in New Issue
Block a user