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
Kirill Smelkov
jio
Commits
d7efabc2
Commit
d7efabc2
authored
Jan 08, 2013
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename secondstorage to sub_storage
parent
6b2cdf90
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
56 deletions
+56
-56
src/jio.storage/conflictmanagerstorage.js
src/jio.storage/conflictmanagerstorage.js
+10
-10
src/jio.storage/cryptstorage.js
src/jio.storage/cryptstorage.js
+7
-7
src/jio.storage/indexstorage.js
src/jio.storage/indexstorage.js
+12
-12
src/jio.storage/revisionstorage.js
src/jio.storage/revisionstorage.js
+2
-2
src/jio.waitstorage.js
src/jio.waitstorage.js
+5
-5
test/jiotests.js
test/jiotests.js
+20
-20
No files found.
src/jio.storage/conflictmanagerstorage.js
View file @
d7efabc2
...
...
@@ -3,18 +3,18 @@ var newConflictManagerStorage = function ( spec, my ) {
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
var
storage_exists
=
(
spec
.
storage
?
true
:
false
);
priv
.
s
econd
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
s
econdstorage_string
=
JSON
.
stringify
(
priv
.
second
storage_spec
);
priv
.
s
ub_
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
s
ub_storage_string
=
JSON
.
stringify
(
priv
.
sub_
storage_spec
);
var
local_namespace
=
'
jio/conflictmanager/
'
+
priv
.
s
econd
storage_string
+
'
/
'
;
priv
.
s
ub_
storage_string
+
'
/
'
;
var
empty_fun
=
function
(){};
var
super_serialized
=
that
.
serialized
;
that
.
serialized
=
function
()
{
var
o
=
super_serialized
();
o
.
storage
=
priv
.
s
econd
storage_spec
;
o
.
storage
=
priv
.
s
ub_
storage_spec
;
return
o
;
};
...
...
@@ -28,29 +28,29 @@ var newConflictManagerStorage = function ( spec, my ) {
priv
.
getDistantMetadata
=
function
(
command
,
path
,
success
,
error
)
{
var
cloned_option
=
command
.
cloneOption
();
cloned_option
.
metadata_only
=
false
;
that
.
addJob
(
'
get
'
,
priv
.
s
econd
storage_spec
,
path
,
cloned_option
,
that
.
addJob
(
'
get
'
,
priv
.
s
ub_
storage_spec
,
path
,
cloned_option
,
success
,
error
);
};
priv
.
saveMetadataToDistant
=
function
(
command
,
path
,
content
,
success
,
error
)
{
that
.
addJob
(
'
put
'
,
priv
.
s
econd
storage_spec
,
that
.
addJob
(
'
put
'
,
priv
.
s
ub_
storage_spec
,
{
_id
:
path
,
content
:
JSON
.
stringify
(
content
)},
command
.
cloneOption
(),
success
,
error
);
};
priv
.
saveNewRevision
=
function
(
command
,
path
,
content
,
success
,
error
)
{
that
.
addJob
(
'
post
'
,
priv
.
s
econd
storage_spec
,{
_id
:
path
,
content
:
content
},
that
.
addJob
(
'
post
'
,
priv
.
s
ub_
storage_spec
,{
_id
:
path
,
content
:
content
},
command
.
cloneOption
(),
success
,
error
);
};
priv
.
loadRevision
=
function
(
command
,
path
,
success
,
error
)
{
that
.
addJob
(
'
get
'
,
priv
.
s
econd
storage_spec
,
path
,
command
.
cloneOption
(),
that
.
addJob
(
'
get
'
,
priv
.
s
ub_
storage_spec
,
path
,
command
.
cloneOption
(),
success
,
error
);
};
priv
.
deleteAFile
=
function
(
command
,
path
,
success
,
error
)
{
var
cloned_option
=
command
.
cloneOption
();
that
.
addJob
(
'
remove
'
,
priv
.
s
econd
storage_spec
,{
_id
:
path
},
that
.
addJob
(
'
remove
'
,
priv
.
s
ub_
storage_spec
,{
_id
:
path
},
command
.
cloneOption
(),
success
,
error
);
};
...
...
@@ -654,7 +654,7 @@ var newConflictManagerStorage = function ( spec, my ) {
am
.
call
(
o
,
'
error
'
,[
error
]);
};
cloned_option
.
metadata_only
=
true
;
that
.
addJob
(
'
allDocs
'
,
priv
.
s
econd
storage_spec
,
null
,
cloned_option
,
that
.
addJob
(
'
allDocs
'
,
priv
.
s
ub_
storage_spec
,
null
,
cloned_option
,
success
,
error
);
};
o
.
filterTheList
=
function
(
result
)
{
...
...
src/jio.storage/cryptstorage.js
View file @
d7efabc2
...
...
@@ -6,15 +6,15 @@ var newCryptedStorage = function ( spec, my ) {
priv
.
username
=
spec
.
username
||
''
;
priv
.
password
=
spec
.
password
||
''
;
priv
.
s
econd
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
s
econdstorage_string
=
JSON
.
stringify
(
priv
.
second
storage_string
);
priv
.
s
ub_
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
s
ub_storage_string
=
JSON
.
stringify
(
priv
.
sub_
storage_string
);
var
super_serialized
=
that
.
serialized
;
that
.
serialized
=
function
()
{
var
o
=
super_serialized
();
o
.
username
=
priv
.
username
;
o
.
password
=
priv
.
password
;
// TODO : unsecured !!!
o
.
storage
=
priv
.
s
econd
storage_string
;
o
.
storage
=
priv
.
s
ub_
storage_string
;
return
o
;
};
...
...
@@ -129,7 +129,7 @@ var newCryptedStorage = function ( spec, my ) {
cloned_doc
=
command
.
cloneDoc
();
cloned_doc
.
_id
=
new_file_name
;
cloned_doc
.
content
=
new_file_content
;
that
.
addJob
(
'
put
'
,
priv
.
s
econd
storage_spec
,
cloned_doc
,
that
.
addJob
(
'
put
'
,
priv
.
s
ub_
storage_spec
,
cloned_doc
,
command
.
cloneOption
(),
success
,
error
);
};
am
.
wait
(
o
,
'
save
'
,
1
);
...
...
@@ -150,7 +150,7 @@ var newCryptedStorage = function ( spec, my ) {
});
};
o
.
get
=
function
()
{
that
.
addJob
(
'
get
'
,
priv
.
s
econd
storage_spec
,
new_file_name
,
that
.
addJob
(
'
get
'
,
priv
.
s
ub_
storage_spec
,
new_file_name
,
command
.
cloneOption
(),
o
.
success
,
o
.
error
);
};
o
.
success
=
function
(
val
)
{
...
...
@@ -181,7 +181,7 @@ var newCryptedStorage = function ( spec, my ) {
that
.
allDocs
=
function
(
command
)
{
var
result_array
=
[],
am
=
priv
.
newAsyncModule
(),
o
=
{};
o
.
allDocs
=
function
()
{
that
.
addJob
(
'
allDocs
'
,
priv
.
s
econd
storage_spec
,
null
,
that
.
addJob
(
'
allDocs
'
,
priv
.
s
ub_
storage_spec
,
null
,
command
.
cloneOption
(),
o
.
onSuccess
,
o
.
error
);
};
o
.
onSuccess
=
function
(
val
)
{
...
...
@@ -247,7 +247,7 @@ var newCryptedStorage = function ( spec, my ) {
o
.
removeDocument
=
function
()
{
var
cloned_doc
=
command
.
cloneDoc
();
cloned_doc
.
_id
=
new_file_name
;
that
.
addJob
(
'
remove
'
,
priv
.
s
econd
storage_spec
,
cloned_doc
,
that
.
addJob
(
'
remove
'
,
priv
.
s
ub_
storage_spec
,
cloned_doc
,
command
.
cloneOption
(),
o
.
success
,
that
.
error
);
};
o
.
success
=
function
(
val
)
{
...
...
src/jio.storage/indexstorage.js
View file @
d7efabc2
...
...
@@ -2,23 +2,23 @@ var newIndexStorage = function ( spec, my ) {
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
var
validatestate_s
econd
storage
=
spec
.
storage
||
false
;
priv
.
s
econd
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
s
econdstorage_string
=
JSON
.
stringify
(
priv
.
second
storage_spec
);
var
validatestate_s
ub_
storage
=
spec
.
storage
||
false
;
priv
.
s
ub_
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
s
ub_storage_string
=
JSON
.
stringify
(
priv
.
sub_
storage_spec
);
var
storage_object_name
=
'
jio/indexed_storage_object
'
;
var
storage_file_object_name
=
'
jio/indexed_file_object/
'
+
priv
.
s
econd
storage_string
;
priv
.
s
ub_
storage_string
;
var
super_serialized
=
that
.
serialized
;
that
.
serialized
=
function
()
{
var
o
=
super_serialized
();
o
.
storage
=
priv
.
s
econd
storage_spec
;
o
.
storage
=
priv
.
s
ub_
storage_spec
;
return
o
;
};
that
.
validateState
=
function
()
{
if
(
!
validatestate_s
econd
storage
)
{
if
(
!
validatestate_s
ub_
storage
)
{
return
'
Need at least one parameter: "storage"
'
+
'
containing storage specifications.
'
;
}
...
...
@@ -38,7 +38,7 @@ var newIndexStorage = function ( spec, my ) {
priv
.
indexStorage
=
function
()
{
var
obj
=
localStorage
.
getItem
(
storage_object_name
)
||
{};
obj
[
priv
.
s
econd
storage_spec
]
=
new
Date
().
getTime
();
obj
[
priv
.
s
ub_
storage_spec
]
=
new
Date
().
getTime
();
localStorage
.
setItem
(
storage_object_name
,
obj
);
};
...
...
@@ -99,7 +99,7 @@ var newIndexStorage = function ( spec, my ) {
var
success
=
function
(
val
)
{
priv
.
setFileArray
(
val
.
rows
);
};
that
.
addJob
(
'
allDocs
'
,
priv
.
s
econd
storage_spec
,
null
,
that
.
addJob
(
'
allDocs
'
,
priv
.
s
ub_
storage_spec
,
null
,
{
max_retry
:
3
},
success
,
function
(){});
};
...
...
@@ -122,7 +122,7 @@ var newIndexStorage = function ( spec, my ) {
that
.
error
(
err
);
};
priv
.
indexStorage
();
that
.
addJob
(
'
put
'
,
priv
.
s
econd
storage_spec
,
cloned_doc
,
that
.
addJob
(
'
put
'
,
priv
.
s
ub_
storage_spec
,
cloned_doc
,
cloned_option
,
success
,
error
);
};
// end put
...
...
@@ -140,7 +140,7 @@ var newIndexStorage = function ( spec, my ) {
},
get
=
function
()
{
var
cloned_option
=
command
.
cloneOption
();
that
.
addJob
(
'
get
'
,
priv
.
s
econd
storage_spec
,
command
.
cloneDoc
(),
that
.
addJob
(
'
get
'
,
priv
.
s
ub_
storage_spec
,
command
.
cloneDoc
(),
cloned_option
,
success
,
error
);
that
.
end
();
};
...
...
@@ -181,7 +181,7 @@ var newIndexStorage = function ( spec, my ) {
error
=
function
(
err
)
{
that
.
error
(
err
);
};
that
.
addJob
(
'
allDocs
'
,
priv
.
s
econd
storage_spec
,
null
,
that
.
addJob
(
'
allDocs
'
,
priv
.
s
ub_
storage_spec
,
null
,
command
.
cloneOption
(),
success
,
error
);
}
};
// end allDocs
...
...
@@ -199,7 +199,7 @@ var newIndexStorage = function ( spec, my ) {
error
=
function
(
err
)
{
that
.
error
(
err
);
};
that
.
addJob
(
'
remove
'
,
priv
.
s
econd
storage_spec
,
command
.
cloneDoc
(),
that
.
addJob
(
'
remove
'
,
priv
.
s
ub_
storage_spec
,
command
.
cloneDoc
(),
command
.
cloneOption
(),
success
,
error
);
};
// end remove
...
...
src/jio.storage/revisionstorage.js
View file @
d7efabc2
...
...
@@ -4,7 +4,7 @@
* Description:
* {
* "type": "revision",
* "s
econd
storage": <sub storage description>
* "s
ub_
storage": <sub storage description>
* }
*/
jIO
.
addStorageType
(
'
revision
'
,
function
(
spec
,
my
)
{
...
...
@@ -13,7 +13,7 @@ jIO.addStorageType('revision', function (spec, my) {
spec
=
spec
||
{};
that
=
my
.
basicStorage
(
spec
,
my
);
priv
.
substorage_key
=
"
s
econd
storage
"
;
priv
.
substorage_key
=
"
s
ub_
storage
"
;
priv
.
doctree_suffix
=
"
.revision_tree.json
"
;
priv
.
substorage
=
spec
[
priv
.
substorage_key
];
...
...
src/jio.waitstorage.js
View file @
d7efabc2
...
...
@@ -3,8 +3,8 @@
var
newWaitStorage
=
function
(
spec
,
my
)
{
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
var
validatestate_s
econd
storage
=
spec
.
storage
||
false
;
priv
.
s
econd
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
var
validatestate_s
ub_
storage
=
spec
.
storage
||
false
;
priv
.
s
ub_
storage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
delay
=
spec
.
delay
||
5000
;
priv
.
save
=
spec
.
save
||
true
;
priv
.
load
=
spec
.
load
||
false
;
...
...
@@ -12,7 +12,7 @@
priv
.
remove
=
spec
.
remove
||
false
;
that
.
validateState
=
function
()
{
if
(
!
validatestate_s
econd
storage
)
{
if
(
!
validatestate_s
ub_
storage
)
{
return
'
Need at least one parameter: "storage"
'
+
'
containing storage specifications.
'
;
}
...
...
@@ -22,7 +22,7 @@
that
.
specToStore
=
function
()
{
var
o
=
{};
o
.
delay
=
priv
.
delay
;
o
.
storage
=
priv
.
s
econd
storage_spec
;
o
.
storage
=
priv
.
s
ub_
storage_spec
;
o
.
save
=
priv
.
save
;
o
.
load
=
priv
.
load
;
o
.
getlist
=
priv
.
getlist
;
...
...
@@ -36,7 +36,7 @@
delay
=
priv
.
delay
;
}
setTimeout
(
function
()
{
that
.
addJob
(
that
.
newStorage
(
priv
.
s
econd
storage_spec
),
that
.
addJob
(
that
.
newStorage
(
priv
.
s
ub_
storage_spec
),
command
);
that
.
end
();
},
delay
);
...
...
test/jiotests.js
View file @
d7efabc2
...
...
@@ -1084,7 +1084,7 @@ test ("Post", function(){
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
revision
"
,
"
s
econd
storage
"
:
{
"
s
ub_
storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
urevpost
"
,
"
applicationname
"
:
"
arevpost
"
...
...
@@ -1156,7 +1156,7 @@ test ("Put", function(){
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
revision
"
,
"
s
econd
storage
"
:
{
"
s
ub_
storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
urevput
"
,
"
applicationname
"
:
"
arevput
"
...
...
@@ -1215,7 +1215,7 @@ test ("Get", function(){
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
revision
"
,
"
s
econd
storage
"
:
{
"
s
ub_
storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
urevget
"
,
"
applicationname
"
:
"
arevget
"
...
...
@@ -1369,7 +1369,7 @@ test ("Remove", function(){
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
revision
"
,
"
s
econd
storage
"
:
{
"
s
ub_
storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
urevrem
"
,
"
applicationname
"
:
"
arevrem
"
...
...
@@ -1572,7 +1572,7 @@ test ("Scenario", function(){
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
revision
"
,
"
s
econd
storage
"
:
{
"
s
ub_
storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
usam1
"
,
"
applicationname
"
:
"
asam1
"
...
...
@@ -1598,7 +1598,7 @@ test ("Scenario", function(){
// open new tab (JIO)
o
.
jio2
=
JIO
.
newJio
({
"
type
"
:
"
revision
"
,
"
s
econd
storage
"
:
{
"
s
ub_
storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
usam1
"
,
"
applicationname
"
:
"
asam1
"
...
...
@@ -1655,7 +1655,7 @@ test ("Scenario", function(){
// Reopen JIO
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
revision
"
,
"
s
econd
storage
"
:
{
"
s
ub_
storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
usam1
"
,
"
applicationname
"
:
"
asam1
"
...
...
@@ -2213,11 +2213,11 @@ test ('Get document list', function () {
test ('Remove document', function () {
var o = {}; o.clock = this.sandbox.useFakeTimers();
o.clock.tick(base_tick);
o.s
econd
storage = {type:'dummyall3tries',username:'indexremove'}
o.s
ub_
storage = {type:'dummyall3tries',username:'indexremove'}
o.storage_file_object_name = 'jio/indexed_file_object/'+
JSON.stringify (o.s
econd
storage);
JSON.stringify (o.s
ub_
storage);
o.jio = JIO.newJio({type:'indexed',storage:o.s
econd
storage});
o.jio = JIO.newJio({type:'indexed',storage:o.s
ub_
storage});
o.f = function (err,val) {
if (err) {
err = err.status;
...
...
@@ -2586,12 +2586,12 @@ test ('Revision Conflict', function() {
ok (!LocalOrCookieStorage.getItem(o.localNamespace + string),
message || '"' + string + '" does not exists.');
};
o.s
econd
storage_spec = {type:'local',
o.s
ub_
storage_spec = {type:'local',
username:'revisionconflict',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.s
econd
storage_spec});
storage:o.s
ub_
storage_spec});
// create a new file
o.spy(o,'value',
{ok:true,id:'file.doc',rev:'1',conflicts:{total_rows:0,rows:[]},
...
...
@@ -2750,12 +2750,12 @@ test ('Conflict in a conflict solving', function () {
ok (!LocalOrCookieStorage.getItem(o.localNamespace + string),
message || '"' + string + '" does not exists.');
};
o.s
econd
storage_spec = {type:'local',
o.s
ub_
storage_spec = {type:'local',
username:'conflictconflict',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.s
econd
storage_spec});
storage:o.s
ub_
storage_spec});
// create a new file
o.test_message = 'new file "file.doc", revision: "0".'
o.f = o.t.spy();
...
...
@@ -2937,12 +2937,12 @@ test ('Remove revision conflict', function () {
ok (!LocalOrCookieStorage.getItem(o.localNamespace + string),
message || '"' + string + '" does not exists.');
};
o.s
econd
storage_spec = {type:'local',
o.s
ub_
storage_spec = {type:'local',
username:'removeconflict',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.s
econd
storage_spec});
storage:o.s
ub_
storage_spec});
o.test_message = 'new file "file.doc", revision: "0".';
o.f = o.t.spy();
...
...
@@ -3167,12 +3167,12 @@ test ('Load Revisions', function () {
o.clock.tick (base_tick);
o.spy = basic_spy_function;
o.tick = basic_tick_function;
o.s
econd
storage_spec = {type:'local',
o.s
ub_
storage_spec = {type:'local',
username:'loadrevisions',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.s
econd
storage_spec});
storage:o.s
ub_
storage_spec});
o.spy(o,'status',404,'load file rev:1,','f'); // 12 === Replaced
o.spy(o,'status',404,'load file rev:2','g');
o.spy(o,'status',404,'and load file rev:3 at the same time','h');
...
...
@@ -3188,13 +3188,13 @@ test ('Get revision List', function () {
o.clock.tick (base_tick);
o.spy = basic_spy_function;
o.tick = basic_tick_function;
o.s
econd
storage_spec = {type:'local',
o.s
ub_
storage_spec = {type:'local',
username:'getrevisionlist',
applicationname:'jiotests'}
o.rev = {};
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.s
econd
storage_spec});
storage:o.s
ub_
storage_spec});
o.spy(o,'value',{total_rows:0,rows:[]},'Get revision list');
o.jio.allDocs(o.f);
o.tick(o);
...
...
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