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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
1e7672c7
Commit
1e7672c7
authored
Sep 02, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage wrong status returned -> fixed
parent
e34cc4eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+10
-4
test/jio.storage/localstorage.tests.js
test/jio.storage/localstorage.tests.js
+6
-6
No files found.
src/jio.storage/localstorage.js
View file @
1e7672c7
...
...
@@ -187,21 +187,23 @@
* @param {Object} options The command options
*/
LocalStorage
.
prototype
.
put
=
function
(
command
,
metadata
)
{
var
doc
,
tmp
;
var
doc
,
tmp
,
status
;
doc
=
this
.
_storage
.
getItem
(
this
.
_localpath
+
"
/
"
+
metadata
.
_id
);
if
(
doc
===
null
)
{
// the document does not exist
doc
=
jIO
.
util
.
deepClone
(
metadata
);
delete
doc
.
_attachments
;
status
=
"
created
"
;
}
else
{
// the document already exists
tmp
=
jIO
.
util
.
deepClone
(
metadata
);
tmp
.
_attachments
=
doc
.
_attachments
;
doc
=
tmp
;
status
=
"
ok
"
;
}
// write
this
.
_storage
.
setItem
(
this
.
_localpath
+
"
/
"
+
metadata
.
_id
,
doc
);
command
.
success
();
command
.
success
(
status
);
};
/**
...
...
@@ -213,7 +215,7 @@
* @param {Object} options The command options
*/
LocalStorage
.
prototype
.
putAttachment
=
function
(
command
,
param
)
{
var
that
=
this
,
doc
;
var
that
=
this
,
doc
,
status
=
"
ok
"
;
doc
=
this
.
_storage
.
getItem
(
this
.
_localpath
+
"
/
"
+
param
.
_id
);
if
(
doc
===
null
)
{
// the document does not exist
...
...
@@ -228,6 +230,9 @@
// download data
jIO
.
util
.
readBlobAsBinaryString
(
param
.
_blob
).
then
(
function
(
e
)
{
doc
.
_attachments
=
doc
.
_attachments
||
{};
if
(
doc
.
_attachments
[
param
.
_attachment
])
{
status
=
"
created
"
;
}
doc
.
_attachments
[
param
.
_attachment
]
=
{
"
content_type
"
:
param
.
_blob
.
type
,
"
digest
"
:
jIO
.
util
.
makeBinaryStringDigest
(
e
.
target
.
result
),
...
...
@@ -237,7 +242,8 @@
that
.
_storage
.
setItem
(
that
.
_localpath
+
"
/
"
+
param
.
_id
+
"
/
"
+
param
.
_attachment
,
e
.
target
.
result
);
that
.
_storage
.
setItem
(
that
.
_localpath
+
"
/
"
+
param
.
_id
,
doc
);
command
.
success
({
"
hash
"
:
doc
.
_attachments
[
param
.
_attachment
].
digest
});
command
.
success
(
status
,
{
"
hash
"
:
doc
.
_attachments
[
param
.
_attachment
].
digest
});
},
function
(
e
)
{
command
.
error
(
"
request_timeout
"
,
...
...
test/jio.storage/localstorage.tests.js
View file @
1e7672c7
...
...
@@ -153,8 +153,8 @@
"
id
"
:
"
put1
"
,
"
method
"
:
"
put
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
0
,
"
statusText
"
:
"
Ok
"
"
status
"
:
20
1
,
"
statusText
"
:
"
Created
"
},
"
Creates a document
"
);
}).
then
(
function
()
{
...
...
@@ -407,8 +407,8 @@
"
id
"
:
"
a
"
,
"
method
"
:
"
removeAttachment
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
0
,
"
statusText
"
:
"
Ok
"
"
status
"
:
20
4
,
"
statusText
"
:
"
No Content
"
},
"
Remove existent attachment
"
);
}).
then
(
function
()
{
...
...
@@ -443,8 +443,8 @@
"
id
"
:
"
a
"
,
"
method
"
:
"
remove
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
0
,
"
statusText
"
:
"
Ok
"
"
status
"
:
20
4
,
"
statusText
"
:
"
No Content
"
},
"
Remove existent document
"
);
}).
then
(
function
()
{
...
...
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