Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Hamza
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
Hide 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 @@
...
@@ -97,13 +97,19 @@
}
}
function
waitForOpenIndexedDB
(
db_name
,
callback
)
{
function
waitForOpenIndexedDB
(
db_name
,
callback
)
{
var
request
;
function
canceller
()
{
if
((
request
!==
undefined
)
&&
(
request
.
result
!==
undefined
))
{
request
.
result
.
close
();
}
}
function
resolver
(
resolve
,
reject
)
{
function
resolver
(
resolve
,
reject
)
{
// Open DB //
// Open DB //
var
request
=
indexedDB
.
open
(
db_name
);
request
=
indexedDB
.
open
(
db_name
);
request
.
onerror
=
function
(
error
)
{
request
.
onerror
=
function
(
error
)
{
if
(
request
.
result
)
{
canceller
();
request
.
result
.
close
();
}
if
((
error
!==
undefined
)
&&
if
((
error
!==
undefined
)
&&
(
error
.
target
instanceof
IDBOpenDBRequest
)
&&
(
error
.
target
instanceof
IDBOpenDBRequest
)
&&
(
error
.
target
.
error
instanceof
DOMError
))
{
(
error
.
target
.
error
instanceof
DOMError
))
{
...
@@ -115,17 +121,16 @@
...
@@ -115,17 +121,16 @@
};
};
request
.
onabort
=
function
()
{
request
.
onabort
=
function
()
{
request
.
result
.
close
();
canceller
();
reject
(
"
Aborting connection to:
"
+
db_name
);
reject
(
"
Aborting connection to:
"
+
db_name
);
};
};
request
.
ontimeout
=
function
()
{
request
.
ontimeout
=
function
()
{
request
.
result
.
close
();
reject
(
"
Connection to:
"
+
db_name
+
"
timeout
"
);
reject
(
"
Connection to:
"
+
db_name
+
"
timeout
"
);
};
};
request
.
onblocked
=
function
()
{
request
.
onblocked
=
function
()
{
request
.
result
.
close
();
canceller
();
reject
(
"
Connection to:
"
+
db_name
+
"
was blocked
"
);
reject
(
"
Connection to:
"
+
db_name
+
"
was blocked
"
);
};
};
...
@@ -133,26 +138,32 @@
...
@@ -133,26 +138,32 @@
request
.
onupgradeneeded
=
handleUpgradeNeeded
;
request
.
onupgradeneeded
=
handleUpgradeNeeded
;
request
.
onversionchange
=
function
()
{
request
.
onversionchange
=
function
()
{
request
.
result
.
close
();
canceller
();
reject
(
db_name
+
"
was upgraded
"
);
reject
(
db_name
+
"
was upgraded
"
);
};
};
request
.
onsuccess
=
function
()
{
request
.
onsuccess
=
function
()
{
var
result
;
try
{
result
=
callback
(
request
.
result
);
}
catch
(
error
)
{
reject
(
error
);
}
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
callback
(
request
.
result
)
;
return
result
;
})
})
.
push
(
function
(
result
)
{
.
push
(
function
(
final_
result
)
{
request
.
result
.
close
();
canceller
();
resolve
(
result
);
resolve
(
final_
result
);
},
function
(
error
)
{
},
function
(
error
)
{
request
.
result
.
close
();
canceller
();
reject
(
error
);
reject
(
error
);
});
});
};
};
}
}
return
new
RSVP
.
Promise
(
resolver
);
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
}
function
waitForTransaction
(
db
,
stores
,
flag
,
callback
)
{
function
waitForTransaction
(
db
,
stores
,
flag
,
callback
)
{
...
@@ -182,14 +193,8 @@
...
@@ -182,14 +193,8 @@
reject
(
error
);
reject
(
error
);
});
});
};
};
tx
.
onerror
=
function
(
error
)
{
tx
.
onerror
=
reject
;
canceller
();
tx
.
onabort
=
reject
;
reject
(
error
);
};
tx
.
onabort
=
function
(
evt
)
{
reject
(
evt
.
target
);
};
return
tx
;
}
}
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
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