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
Labels
Merge Requests
18
Merge Requests
18
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
jio
Commits
16ff4896
Commit
16ff4896
authored
Oct 05, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip indexeddb .then
parent
11db1a2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
34 deletions
+16
-34
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+16
-34
No files found.
src/jio.storage/indexeddbstorage.js
View file @
16ff4896
...
...
@@ -346,15 +346,14 @@
return
waitForTransaction
(
db
,
[
"
metadata
"
,
"
attachment
"
,
"
blob
"
],
"
readwrite
"
,
function
(
tx
)
{
var
promise_list
=
[],
result
;
var
promise_list
=
[];
function
deleteEntry
(
cursor
)
{
promise_list
.
push
(
waitForIDBRequest
(
cursor
.
delete
())
);
}
re
sult
=
RSVP
.
all
([
re
turn
RSVP
.
all
([
waitForIDBRequest
(
tx
.
objectStore
(
"
metadata
"
).
delete
(
id
)),
// XXX Why not possible to delete with KeyCursor?
waitForAllSynchronousCursor
(
...
...
@@ -367,12 +366,8 @@
.
openCursor
(
IDBKeyRange
.
only
(
id
)),
deleteEntry
),
]);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
result
;
})
.
push
(
function
()
{
])
.
then
(
function
()
{
return
RSVP
.
all
(
promise_list
);
});
});
...
...
@@ -393,14 +388,10 @@
return
waitForTransaction
(
db
,
[
"
attachment
"
,
"
blob
"
],
"
readonly
"
,
function
(
tx
)
{
// XXX Should raise if key is not good
var
result
=
waitForIDBRequest
(
tx
.
objectStore
(
"
attachment
"
).
get
(
return
waitForIDBRequest
(
tx
.
objectStore
(
"
attachment
"
).
get
(
buildKeyPath
([
id
,
name
])
));
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
result
;
})
.
push
(
function
(
evt
)
{
))
.
then
(
function
(
evt
)
{
var
attachment
=
evt
.
target
.
result
,
total_length
=
attachment
.
info
.
length
,
promise_list
=
[],
...
...
@@ -462,8 +453,7 @@
};
function
removeAttachment
(
tx
,
id
,
name
)
{
var
promise_list
=
[],
result
;
var
promise_list
=
[];
function
deleteEntry
(
cursor
)
{
promise_list
.
push
(
...
...
@@ -471,21 +461,17 @@
);
}
re
sult
=
waitForIDBRequest
(
re
turn
waitForIDBRequest
(
tx
.
objectStore
(
"
attachment
"
).
delete
(
buildKeyPath
([
id
,
name
]))
);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
result
;
})
.
push
(
function
()
{
)
.
then
(
function
()
{
return
waitForAllSynchronousCursor
(
tx
.
objectStore
(
"
blob
"
).
index
(
"
_id_attachment
"
)
.
openCursor
(
IDBKeyRange
.
only
([
id
,
name
])),
deleteEntry
);
})
.
push
(
function
()
{
.
then
(
function
()
{
return
RSVP
.
all
(
promise_list
);
});
}
...
...
@@ -512,13 +498,9 @@
return
waitForOpenIndexedDB
(
db_name
,
function
(
db
)
{
return
waitForTransaction
(
db
,
[
"
attachment
"
,
"
blob
"
],
"
readwrite
"
,
function
(
tx
)
{
var
result
=
removeAttachment
(
tx
,
id
,
name
);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
// First remove the previous attachment
return
result
;
})
.
push
(
function
()
{
// First remove the previous attachment
return
removeAttachment
(
tx
,
id
,
name
)
.
then
(
function
()
{
// Then write the attachment info
return
waitForIDBRequest
(
tx
.
objectStore
(
"
attachment
"
).
put
({
"
_key_path
"
:
buildKeyPath
([
id
,
name
]),
...
...
@@ -530,7 +512,7 @@
}
}));
})
.
push
(
function
()
{
.
then
(
function
()
{
var
blob_store
=
tx
.
objectStore
(
"
blob
"
),
promise_list
=
[],
i
;
...
...
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