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
Roque
jio
Commits
149198e4
Commit
149198e4
authored
Sep 02, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage wrong status returned -> fixed
parent
fd72a86e
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 @
149198e4
...
@@ -187,21 +187,23 @@
...
@@ -187,21 +187,23 @@
* @param {Object} options The command options
* @param {Object} options The command options
*/
*/
LocalStorage
.
prototype
.
put
=
function
(
command
,
metadata
)
{
LocalStorage
.
prototype
.
put
=
function
(
command
,
metadata
)
{
var
doc
,
tmp
;
var
doc
,
tmp
,
status
;
doc
=
this
.
_storage
.
getItem
(
this
.
_localpath
+
"
/
"
+
metadata
.
_id
);
doc
=
this
.
_storage
.
getItem
(
this
.
_localpath
+
"
/
"
+
metadata
.
_id
);
if
(
doc
===
null
)
{
if
(
doc
===
null
)
{
// the document does not exist
// the document does not exist
doc
=
jIO
.
util
.
deepClone
(
metadata
);
doc
=
jIO
.
util
.
deepClone
(
metadata
);
delete
doc
.
_attachments
;
delete
doc
.
_attachments
;
status
=
"
created
"
;
}
else
{
}
else
{
// the document already exists
// the document already exists
tmp
=
jIO
.
util
.
deepClone
(
metadata
);
tmp
=
jIO
.
util
.
deepClone
(
metadata
);
tmp
.
_attachments
=
doc
.
_attachments
;
tmp
.
_attachments
=
doc
.
_attachments
;
doc
=
tmp
;
doc
=
tmp
;
status
=
"
ok
"
;
}
}
// write
// write
this
.
_storage
.
setItem
(
this
.
_localpath
+
"
/
"
+
metadata
.
_id
,
doc
);
this
.
_storage
.
setItem
(
this
.
_localpath
+
"
/
"
+
metadata
.
_id
,
doc
);
command
.
success
();
command
.
success
(
status
);
};
};
/**
/**
...
@@ -213,7 +215,7 @@
...
@@ -213,7 +215,7 @@
* @param {Object} options The command options
* @param {Object} options The command options
*/
*/
LocalStorage
.
prototype
.
putAttachment
=
function
(
command
,
param
)
{
LocalStorage
.
prototype
.
putAttachment
=
function
(
command
,
param
)
{
var
that
=
this
,
doc
;
var
that
=
this
,
doc
,
status
=
"
ok
"
;
doc
=
this
.
_storage
.
getItem
(
this
.
_localpath
+
"
/
"
+
param
.
_id
);
doc
=
this
.
_storage
.
getItem
(
this
.
_localpath
+
"
/
"
+
param
.
_id
);
if
(
doc
===
null
)
{
if
(
doc
===
null
)
{
// the document does not exist
// the document does not exist
...
@@ -228,6 +230,9 @@
...
@@ -228,6 +230,9 @@
// download data
// download data
jIO
.
util
.
readBlobAsBinaryString
(
param
.
_blob
).
then
(
function
(
e
)
{
jIO
.
util
.
readBlobAsBinaryString
(
param
.
_blob
).
then
(
function
(
e
)
{
doc
.
_attachments
=
doc
.
_attachments
||
{};
doc
.
_attachments
=
doc
.
_attachments
||
{};
if
(
doc
.
_attachments
[
param
.
_attachment
])
{
status
=
"
created
"
;
}
doc
.
_attachments
[
param
.
_attachment
]
=
{
doc
.
_attachments
[
param
.
_attachment
]
=
{
"
content_type
"
:
param
.
_blob
.
type
,
"
content_type
"
:
param
.
_blob
.
type
,
"
digest
"
:
jIO
.
util
.
makeBinaryStringDigest
(
e
.
target
.
result
),
"
digest
"
:
jIO
.
util
.
makeBinaryStringDigest
(
e
.
target
.
result
),
...
@@ -237,7 +242,8 @@
...
@@ -237,7 +242,8 @@
that
.
_storage
.
setItem
(
that
.
_localpath
+
"
/
"
+
param
.
_id
+
"
/
"
+
that
.
_storage
.
setItem
(
that
.
_localpath
+
"
/
"
+
param
.
_id
+
"
/
"
+
param
.
_attachment
,
e
.
target
.
result
);
param
.
_attachment
,
e
.
target
.
result
);
that
.
_storage
.
setItem
(
that
.
_localpath
+
"
/
"
+
param
.
_id
,
doc
);
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
)
{
},
function
(
e
)
{
command
.
error
(
command
.
error
(
"
request_timeout
"
,
"
request_timeout
"
,
...
...
test/jio.storage/localstorage.tests.js
View file @
149198e4
...
@@ -153,8 +153,8 @@
...
@@ -153,8 +153,8 @@
"
id
"
:
"
put1
"
,
"
id
"
:
"
put1
"
,
"
method
"
:
"
put
"
,
"
method
"
:
"
put
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
0
,
"
status
"
:
20
1
,
"
statusText
"
:
"
Ok
"
"
statusText
"
:
"
Created
"
},
"
Creates a document
"
);
},
"
Creates a document
"
);
}).
then
(
function
()
{
}).
then
(
function
()
{
...
@@ -407,8 +407,8 @@
...
@@ -407,8 +407,8 @@
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
removeAttachment
"
,
"
method
"
:
"
removeAttachment
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
0
,
"
status
"
:
20
4
,
"
statusText
"
:
"
Ok
"
"
statusText
"
:
"
No Content
"
},
"
Remove existent attachment
"
);
},
"
Remove existent attachment
"
);
}).
then
(
function
()
{
}).
then
(
function
()
{
...
@@ -443,8 +443,8 @@
...
@@ -443,8 +443,8 @@
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
remove
"
,
"
method
"
:
"
remove
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
0
,
"
status
"
:
20
4
,
"
statusText
"
:
"
Ok
"
"
statusText
"
:
"
No Content
"
},
"
Remove existent document
"
);
},
"
Remove existent document
"
);
}).
then
(
function
()
{
}).
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