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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
jio
Commits
12f16a47
Commit
12f16a47
authored
Jan 08, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix remove attachment
parent
f75085c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
144 additions
and
47 deletions
+144
-47
src/jio.storage/revisionstorage.js
src/jio.storage/revisionstorage.js
+137
-42
test/jiotests.js
test/jiotests.js
+7
-5
No files found.
src/jio.storage/revisionstorage.js
View file @
12f16a47
...
@@ -272,11 +272,13 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -272,11 +272,13 @@ jIO.addStorageType('revision', function (spec, my) {
"
rev
"
:
next_rev
.
join
(
'
-
'
),
"
rev
"
:
next_rev
.
join
(
'
-
'
),
"
status
"
:
flag
"
status
"
:
flag
});
});
selected_node
.
children
.
unshift
({
selected_node
.
children
.
unshift
({
"
rev
"
:
next_rev
.
join
(
'
-
'
),
"
rev
"
:
next_rev
.
join
(
'
-
'
),
"
status
"
:
flag
,
"
status
"
:
flag
,
"
children
"
:
[]
"
children
"
:
[]
});
});
return
revs_info
;
return
revs_info
;
};
};
...
@@ -648,8 +650,7 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -648,8 +650,7 @@ jIO.addStorageType('revision', function (spec, my) {
* @param {object} command The JIO command
* @param {object} command The JIO command
*/
*/
that
.
remove
=
function
(
command
)
{
that
.
remove
=
function
(
command
)
{
var
f
=
{},
del_rev
,
option
,
i
,
var
f
=
{},
del_rev
,
option
,
new_doc
,
revs_info
,
new_id
;
revision_found
=
false
,
revision_count
=
0
,
correct_revision
;
option
=
command
.
cloneOption
();
option
=
command
.
cloneOption
();
if
(
option
[
"
max_retry
"
]
===
0
)
{
if
(
option
[
"
max_retry
"
]
===
0
)
{
option
[
"
max_retry
"
]
=
3
;
option
[
"
max_retry
"
]
=
3
;
...
@@ -658,31 +659,126 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -658,31 +659,126 @@ jIO.addStorageType('revision', function (spec, my) {
f
.
removeDocument
=
function
(
docid
,
doctree
)
{
f
.
removeDocument
=
function
(
docid
,
doctree
)
{
if
(
command
.
getOption
(
"
keep_revision_history
"
)
!==
true
)
{
if
(
command
.
getOption
(
"
keep_revision_history
"
)
!==
true
)
{
that
.
addJob
(
if
(
command
.
getAttachmentId
()
===
undefined
){
"
remove
"
,
priv
.
substorage
,
// update tree
docid
,
priv
.
postToDocumentTree
(
doctree
,
command
.
getDoc
(),
true
);
option
,
function
(
response
)
{
// remove revision
if
(
typeof
command
.
getAttachmentId
()
===
undefined
){
that
.
addJob
(
priv
.
postToDocumentTree
(
doctree
,
command
.
getDoc
(),
"
remove
"
,
true
priv
.
substorage
,
docid
,
option
,
function
(
response
)
{
// put tree
that
.
addJob
(
"
put
"
,
priv
.
substorage
,
doctree
,
command
.
cloneOption
(),
function
(
response
)
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
docid
,
"
rev
"
:
revs_info
[
0
].
rev
});
},
function
(
err
){
that
.
error
({
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
,
"
error
"
:
"
conflict
"
,
"
message
"
:
"
Document update conflict.
"
,
"
reason
"
:
"
Cannot update document tree
"
});
return
;
}
);
);
}
else
{
},
priv
.
postToDocumentTree
(
doctree
,
command
.
getDoc
());
function
(
err
)
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
File not found
"
,
"
reason
"
:
"
Document was not found
"
});
return
;
}
}
},
);
function
(
err
)
{
}
else
{
that
.
error
({
// get previsous document
"
status
"
:
404
,
that
.
addJob
(
"
statusText
"
:
"
Not Found
"
,
"
get
"
,
"
error
"
:
"
not_found
"
,
priv
.
substorage
,
"
message
"
:
"
File not found
"
,
command
.
getDocId
()
+
"
.
"
+
del_rev
,
"
reason
"
:
"
Document was not found
"
option
,
});
function
(
response
)
{
return
;
// update tree
}
revs_info
=
priv
.
postToDocumentTree
(
doctree
,
);
command
.
getDoc
());
new_doc
=
response
;
delete
new_doc
.
_attachments
;
new_doc
.
_id
=
new_doc
.
_id
+
"
.
"
+
revs_info
[
0
].
rev
;
// post new document version
that
.
addJob
(
"
post
"
,
priv
.
substorage
,
new_doc
,
command
.
cloneOption
(),
function
(
response
)
{
// put tree
doctree
.
_id
=
command
.
getDocId
()
+
priv
.
doctree_suffix
;
that
.
addJob
(
"
put
"
,
priv
.
substorage
,
doctree
,
command
.
cloneOption
(),
function
(
response
)
{
that
.
success
({
"
ok
"
:
true
,
"
id
"
:
new_doc
.
_id
,
"
rev
"
:
revs_info
[
0
].
rev
});
},
function
(
err
)
{
err
.
message
=
"
Cannot save document revision tree
"
;
that
.
error
(
err
);
}
);
},
function
(
err
){
that
.
error
({
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
,
"
error
"
:
"
conflict
"
,
"
message
"
:
"
Document update conflict.
"
,
"
reason
"
:
"
Cannot update document
"
});
return
;
}
);
},
function
(
err
)
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
File not found
"
,
"
reason
"
:
"
Document was not found
"
});
return
;
}
);
}
}
else
{
}
else
{
// keep history = update document tree only
// keep history = update document tree only
}
}
...
@@ -722,25 +818,24 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -722,25 +818,24 @@ jIO.addStorageType('revision', function (spec, my) {
return
;
return
;
}
else
{
}
else
{
// revision provided
// revision provided
if
(
typeof
command
.
getAttachmentId
()
===
"
string
"
){
if
(
priv
.
isRevisionALeaf
(
response
,
del_rev
)
===
true
){
f
.
removeDocument
(
command
.
getDocId
()
+
"
.
"
+
del_rev
+
"
/
"
+
if
(
typeof
command
.
getAttachmentId
()
===
"
string
"
){
command
.
getAttachmentId
(),
response
);
f
.
removeDocument
(
command
.
getDocId
()
+
"
.
"
+
del_rev
+
}
else
{
"
/
"
+
command
.
getAttachmentId
(),
response
);
// loop leaves
if
(
priv
.
isRevisionALeaf
(
del_rev
,
priv
.
getLeavesFromDocumentTree
(
response
))
===
true
){
f
.
removeDocument
(
command
.
getDocId
()
+
"
.
"
+
del_rev
,
response
);
}
else
{
}
else
{
that
.
error
({
f
.
removeDocument
(
command
.
getDocId
()
+
"
.
"
+
del_rev
,
"
status
"
:
409
,
response
"
statusText
"
:
"
Conflict
"
,
);
"
error
"
:
"
conflict
"
,
"
message
"
:
"
Document update conflict.
"
,
"
reason
"
:
"
Trying to remove non-latest revision
"
});
return
;
}
}
}
else
{
that
.
error
({
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
,
"
error
"
:
"
conflict
"
,
"
message
"
:
"
Document update conflict.
"
,
"
reason
"
:
"
Trying to remove non-latest revision
"
});
return
;
}
}
}
}
},
},
...
...
test/jiotests.js
View file @
12f16a47
...
@@ -1424,7 +1424,8 @@ test ("Remove", function(){
...
@@ -1424,7 +1424,8 @@ test ("Remove", function(){
o
.
rev
=
"
3-
"
+
generateRevisionHash
(
o
.
doc_myremove1
,
o
.
revisions
);
o
.
rev
=
"
3-
"
+
generateRevisionHash
(
o
.
doc_myremove1
,
o
.
revisions
);
// 4. remove existing attachment with revision
// 4. remove existing attachment with revision
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
remove1
"
,
"
rev
"
:
o
.
rev
},
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
remove1.
"
+
o
.
rev
,
"
rev
"
:
o
.
rev
},
"
Remove existing attachment (revision)
"
);
"
Remove existing attachment (revision)
"
);
o
.
jio
.
remove
({
"
_id
"
:
"
remove1/remove2
"
,
"
_rev
"
:
o
.
old_rev
},
o
.
f
);
o
.
jio
.
remove
({
"
_id
"
:
"
remove1/remove2
"
,
"
_rev
"
:
o
.
old_rev
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
@@ -1452,8 +1453,8 @@ test ("Remove", function(){
...
@@ -1452,8 +1453,8 @@ test ("Remove", function(){
// 7. check if document is updated
// 7. check if document is updated
deepEqual
(
localstorage
.
getItem
(
deepEqual
(
localstorage
.
getItem
(
"
jio/localstorage/urevrem/arevrem/remove1.
"
+
o
.
rev
"
jio/localstorage/urevrem/arevrem/remove1.
"
+
o
.
rev
),
{
"
_id
"
:
"
remove1.
"
+
o
.
rev
},
"
Check document
"
);
),
{
"
_id
"
:
"
remove1.
"
+
o
.
rev
,
"
title
"
:
"
myRemove1
"
},
"
Check document
"
);
/*
// add another attachment
// add another attachment
o.attmt_myremove2 = {
o.attmt_myremove2 = {
"remove3": {
"remove3": {
...
@@ -1540,11 +1541,11 @@ test ("Remove", function(){
...
@@ -1540,11 +1541,11 @@ test ("Remove", function(){
o.spy (o,"status", 409, "409 - Removing document (no revision)");
o.spy (o,"status", 409, "409 - Removing document (no revision)");
o.jio.remove({"_id":"remove1"}, o.f);
o.jio.remove({"_id":"remove1"}, o.f);
o.tick(o);
o.tick(o);
*/
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
/*
module ( "Jio Revision Storage + Local Storage" );
module ( "Jio Revision Storage + Local Storage" );
test ("Scenario", function(){
test ("Scenario", function(){
...
@@ -1680,6 +1681,7 @@ test ("Scenario", function(){
...
@@ -1680,6 +1681,7 @@ test ("Scenario", function(){
ok ( o.jio, "Close application");
ok ( o.jio, "Close application");
});
});
*/
/*
/*
module ('Jio DAVStorage');
module ('Jio DAVStorage');
...
...
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