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
b3ae0524
Commit
b3ae0524
authored
Jan 07, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revisionstorage.js get method updated
parent
04bd89df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
39 deletions
+35
-39
src/jio.storage/revisionstorage.js
src/jio.storage/revisionstorage.js
+35
-39
No files found.
src/jio.storage/revisionstorage.js
View file @
b3ae0524
...
@@ -433,12 +433,8 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -433,12 +433,8 @@ jIO.addStorageType('revision', function (spec, my) {
);
);
};
};
f
.
postDocument
=
function
(
doctree_update_method
)
{
f
.
postDocument
=
function
(
doctree_update_method
)
{
revs_info
=
priv
.
postToDocumentTree
(
doctree
,
doc
,
revs_info
=
priv
.
postToDocumentTree
(
doctree
,
doc
);
priv
.
update_doctree_on_remove
);
// I don't understand why?
doc
.
_id
=
docid
+
"
.
"
+
revs_info
[
0
].
rev
;
doc
.
_id
=
docid
+
"
.
"
+
revs_info
[
0
].
rev
;
that
.
addJob
(
that
.
addJob
(
"
post
"
,
"
post
"
,
priv
.
substorage
,
priv
.
substorage
,
...
@@ -511,7 +507,7 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -511,7 +507,7 @@ jIO.addStorageType('revision', function (spec, my) {
* @param {object} command The JIO command
* @param {object} command The JIO command
*/
*/
that
.
get
=
function
(
command
)
{
that
.
get
=
function
(
command
)
{
var
f
=
{},
doctree
,
revs_info
,
prev_rev
,
rev_path
,
option
;
var
f
=
{},
doctree
,
revs_info
,
prev_rev
,
option
;
option
=
command
.
cloneOption
();
option
=
command
.
cloneOption
();
if
(
option
[
"
max_retry
"
]
===
0
)
{
if
(
option
[
"
max_retry
"
]
===
0
)
{
option
[
"
max_retry
"
]
=
3
;
option
[
"
max_retry
"
]
=
3
;
...
@@ -538,11 +534,16 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -538,11 +534,16 @@ jIO.addStorageType('revision', function (spec, my) {
option
,
option
,
function
(
response
)
{
function
(
response
)
{
doctree
=
response
;
doctree
=
response
;
revs_info
=
priv
.
getWinnerRevisionFromDocumentTree
(
doctree
);
if
(
prev_rev
===
undefined
)
{
if
(
prev_rev
===
undefined
)
{
revs_info
=
priv
.
getWinnerRevisionFromDocumentTree
(
doctree
);
prev_rev
=
revs_info
[
0
].
rev
;
prev_rev
=
revs_info
[
0
].
rev
;
}
else
{
revs_info
=
priv
.
getRevisionFromDocumentTree
(
doctree
,
prev_rev
);
}
}
f
.
getDocument
(
command
.
getDocId
()
+
"
.
"
+
prev_rev
);
f
.
getDocument
(
command
.
getDocId
()
+
"
.
"
+
prev_rev
,
command
.
getAttachmentId
());
},
function
(
err
)
{
},
function
(
err
)
{
switch
(
err
.
status
)
{
switch
(
err
.
status
)
{
case
404
:
case
404
:
...
@@ -556,14 +557,36 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -556,14 +557,36 @@ jIO.addStorageType('revision', function (spec, my) {
}
}
);
);
};
};
f
.
getDocument
=
function
(
docid
)
{
f
.
getDocument
=
function
(
docid
,
attmtid
)
{
that
.
addJob
(
that
.
addJob
(
"
get
"
,
"
get
"
,
priv
.
substorage
,
priv
.
substorage
,
docid
,
docid
,
option
,
option
,
function
(
response
)
{
function
(
response
)
{
var
attmt
;
if
(
typeof
response
!==
"
string
"
)
{
if
(
typeof
response
!==
"
string
"
)
{
if
(
attmtid
!==
undefined
)
{
if
(
response
.
_attachments
!==
undefined
)
{
attmt
=
response
.
_attachments
[
attmtid
];
if
(
attmt
!==
undefined
)
{
prev_rev
=
priv
.
getRevisionFromPosition
(
revs_info
,
attmt
.
revpos
);
f
.
getDocument
(
command
.
getDocId
()
+
"
.
"
+
prev_rev
+
"
/
"
+
attmtid
);
return
;
}
}
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Cannot find the attachment
"
,
"
reason
"
:
"
Attachment is missing
"
});
return
;
}
response
.
_id
=
command
.
getDocId
();
response
.
_id
=
command
.
getDocId
();
response
.
_rev
=
prev_rev
;
response
.
_rev
=
prev_rev
;
if
(
command
.
getOption
(
"
revs
"
)
===
true
)
{
if
(
command
.
getOption
(
"
revs
"
)
===
true
)
{
...
@@ -588,36 +611,9 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -588,36 +611,9 @@ jIO.addStorageType('revision', function (spec, my) {
}
}
);
);
};
};
if
(
command
.
getAttachmentId
())
{
if
(
command
.
getAttachmentId
()
&&
prev_rev
!==
undefined
)
{
// xxx: no revision passed = get tree and winning revision
f
.
getDocument
(
command
.
getDocId
()
+
"
.
"
+
prev_rev
+
if
(
prev_rev
===
undefined
){
"
/
"
+
command
.
getAttachmentId
());
that
.
addJob
(
"
get
"
,
priv
.
substorage
,
command
.
getDocId
()
+
priv
.
doctree_suffix
,
option
,
function
(
response
)
{
rev_path
=
"
.
"
+
priv
.
getWinnerRevisionFromDocumentTree
(
response
)[
0
].
rev
;
f
.
getDocument
(
command
.
getDocId
()
+
rev_path
+
"
/
"
+
command
.
getAttachmentId
());
},
function
(
err
)
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Document tree not found, please check document ID
"
,
"
reason
"
:
"
Incorrect document ID
"
});
return
;
}
);
}
else
{
f
.
getDocument
(
command
.
getDocId
()
+
"
.
"
+
prev_rev
+
"
/
"
+
command
.
getAttachmentId
());
}
}
else
{
}
else
{
f
.
getDocumentTree
();
f
.
getDocumentTree
();
}
}
...
...
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