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
Hardik Juneja
jio
Commits
af4bb121
Commit
af4bb121
authored
May 16, 2016
by
Boris Kocherov
Committed by
Vincent Bechu
Oct 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working but bad solution of "transaction close on onsuccess callback ended" problem.
parent
f09ad102
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
45 deletions
+61
-45
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+61
-45
No files found.
src/jio.storage/indexeddbstorage.js
View file @
af4bb121
...
@@ -303,8 +303,7 @@
...
@@ -303,8 +303,7 @@
};
};
IndexedDBStorage
.
prototype
.
getAttachment
=
function
(
id
,
name
,
options
)
{
IndexedDBStorage
.
prototype
.
getAttachment
=
function
(
id
,
name
,
options
)
{
var
transaction
,
var
type
,
type
,
start
,
start
,
end
;
end
;
if
(
options
===
undefined
)
{
if
(
options
===
undefined
)
{
...
@@ -312,48 +311,63 @@
...
@@ -312,48 +311,63 @@
}
}
return
openIndexedDB
(
this
)
return
openIndexedDB
(
this
)
.
push
(
function
(
db
)
{
.
push
(
function
(
db
)
{
transaction
=
openTransaction
(
db
,
[
"
attachment
"
,
"
blob
"
],
"
readonly
"
);
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
// XXX Should raise if key is not good
var
transaction
=
openTransaction
(
db
,
[
"
attachment
"
,
"
blob
"
],
return
handleGet
(
transaction
.
objectStore
(
"
attachment
"
)
"
readonly
"
),
.
get
(
buildKeyPath
([
id
,
name
])));
// XXX Should raise if key is not good
})
request
=
transaction
.
objectStore
(
"
attachment
"
)
.
push
(
function
(
attachment
)
{
.
get
(
buildKeyPath
([
id
,
name
]));
var
total_length
=
attachment
.
info
.
length
,
request
.
onerror
=
function
(
error
)
{
i
,
transaction
.
abort
();
promise_list
=
[],
reject
(
error
);
store
=
transaction
.
objectStore
(
"
blob
"
),
};
start_index
,
request
.
onsuccess
=
function
()
{
end_index
;
var
attachment
=
request
.
result
,
total_length
,
type
=
attachment
.
info
.
content_type
;
i
,
start
=
options
.
start
||
0
;
promise_list
=
[],
end
=
options
.
end
||
total_length
;
store
=
transaction
.
objectStore
(
"
blob
"
),
if
(
end
>
total_length
)
{
start_index
,
end
=
total_length
;
end_index
;
}
if
(
!
attachment
)
{
if
(
start
<
0
||
end
<
0
)
{
return
reject
(
throw
new
jIO
.
util
.
jIOError
(
"
_start and _end must be positive
"
,
new
jIO
.
util
.
jIOError
(
"
Cannot find attachment
"
,
404
)
400
);
);
}
}
if
(
start
>
end
)
{
throw
new
jIO
.
util
.
jIOError
(
"
_start is greater than _end
"
,
total_length
=
attachment
.
info
.
length
;
400
);
type
=
attachment
.
info
.
content_type
;
}
start
=
options
.
start
||
0
;
end
=
options
.
end
||
total_length
;
start_index
=
Math
.
floor
(
start
/
UNITE
);
if
(
end
>
total_length
)
{
end_index
=
Math
.
floor
(
end
/
UNITE
);
end
=
total_length
;
if
(
end
%
UNITE
===
0
)
{
}
end_index
-=
1
;
}
if
(
start
<
0
||
end
<
0
)
{
throw
new
jIO
.
util
.
jIOError
(
"
_start and _end must be positive
"
,
for
(
i
=
start_index
;
i
<=
end_index
;
i
+=
1
)
{
400
);
promise_list
.
push
(
}
handleGet
(
store
.
get
(
buildKeyPath
([
id
,
if
(
start
>
end
)
{
name
,
i
])))
throw
new
jIO
.
util
.
jIOError
(
"
_start is greater than _end
"
,
);
400
);
}
}
return
RSVP
.
all
(
promise_list
);
start_index
=
Math
.
floor
(
start
/
UNITE
);
end_index
=
Math
.
floor
(
end
/
UNITE
);
if
(
end
%
UNITE
===
0
)
{
end_index
-=
1
;
}
for
(
i
=
start_index
;
i
<=
end_index
;
i
+=
1
)
{
promise_list
.
push
(
handleGet
(
store
.
get
(
buildKeyPath
([
id
,
name
,
i
])))
);
}
resolve
(
RSVP
.
all
(
promise_list
));
};
});
})
})
.
push
(
function
(
result_list
)
{
.
push
(
function
(
result_list
)
{
var
array_buffer_list
=
[],
var
array_buffer_list
=
[],
...
@@ -413,10 +427,12 @@
...
@@ -413,10 +427,12 @@
}
}
// Remove previous attachment
// Remove previous attachment
transaction
=
openTransaction
(
db
,
[
"
attachment
"
,
"
blob
"
],
"
readwrite
"
);
transaction
=
openTransaction
(
db
,
[
"
attachment
"
,
"
blob
"
],
"
readwrite
"
,
false
);
return
removeAttachment
(
transaction
,
id
,
name
);
return
removeAttachment
(
transaction
,
id
,
name
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
transaction
=
openTransaction
(
db
,
[
"
attachment
"
,
"
blob
"
],
"
readwrite
"
);
var
promise_list
=
[
var
promise_list
=
[
handleRequest
(
transaction
.
objectStore
(
"
attachment
"
).
put
({
handleRequest
(
transaction
.
objectStore
(
"
attachment
"
).
put
({
...
...
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