Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
preetwinder
jio
Commits
b08e246c
Commit
b08e246c
authored
Mar 22, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IndexedDB] close the DB by cancelling the promise
parent
5ce1c7d2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
22 deletions
+27
-22
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+27
-22
No files found.
src/jio.storage/indexeddbstorage.js
View file @
b08e246c
...
...
@@ -97,13 +97,19 @@
}
function
waitForOpenIndexedDB
(
db_name
,
callback
)
{
var
request
;
function
canceller
()
{
if
((
request
!==
undefined
)
&&
(
request
.
result
!==
undefined
))
{
request
.
result
.
close
();
}
}
function
resolver
(
resolve
,
reject
)
{
// Open DB //
var
request
=
indexedDB
.
open
(
db_name
);
request
=
indexedDB
.
open
(
db_name
);
request
.
onerror
=
function
(
error
)
{
if
(
request
.
result
)
{
request
.
result
.
close
();
}
canceller
();
if
((
error
!==
undefined
)
&&
(
error
.
target
instanceof
IDBOpenDBRequest
)
&&
(
error
.
target
.
error
instanceof
DOMError
))
{
...
...
@@ -115,17 +121,16 @@
};
request
.
onabort
=
function
()
{
request
.
result
.
close
();
canceller
();
reject
(
"
Aborting connection to:
"
+
db_name
);
};
request
.
ontimeout
=
function
()
{
request
.
result
.
close
();
reject
(
"
Connection to:
"
+
db_name
+
"
timeout
"
);
};
request
.
onblocked
=
function
()
{
request
.
result
.
close
();
canceller
();
reject
(
"
Connection to:
"
+
db_name
+
"
was blocked
"
);
};
...
...
@@ -133,26 +138,32 @@
request
.
onupgradeneeded
=
handleUpgradeNeeded
;
request
.
onversionchange
=
function
()
{
request
.
result
.
close
();
canceller
();
reject
(
db_name
+
"
was upgraded
"
);
};
request
.
onsuccess
=
function
()
{
var
result
;
try
{
result
=
callback
(
request
.
result
);
}
catch
(
error
)
{
reject
(
error
);
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
callback
(
request
.
result
)
;
return
result
;
})
.
push
(
function
(
result
)
{
request
.
result
.
close
();
resolve
(
result
);
.
push
(
function
(
final_
result
)
{
canceller
();
resolve
(
final_
result
);
},
function
(
error
)
{
request
.
result
.
close
();
canceller
();
reject
(
error
);
});
};
}
return
new
RSVP
.
Promise
(
resolver
);
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
function
waitForTransaction
(
db
,
stores
,
flag
,
callback
)
{
...
...
@@ -182,14 +193,8 @@
reject
(
error
);
});
};
tx
.
onerror
=
function
(
error
)
{
canceller
();
reject
(
error
);
};
tx
.
onabort
=
function
(
evt
)
{
reject
(
evt
.
target
);
};
return
tx
;
tx
.
onerror
=
reject
;
tx
.
onabort
=
reject
;
}
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment