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
ef27c6fd
Commit
ef27c6fd
authored
Sep 16, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fallbackstorage] allow to support browser without IndexedDB
parent
117e9b18
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
559 additions
and
0 deletions
+559
-0
Makefile
Makefile
+2
-0
src/jio.storage/fallbackstorage.js
src/jio.storage/fallbackstorage.js
+94
-0
test/jio.storage/fallbackstorage.tests.js
test/jio.storage/fallbackstorage.tests.js
+462
-0
test/tests.html
test/tests.html
+1
-0
No files found.
Makefile
View file @
ef27c6fd
...
...
@@ -132,6 +132,7 @@ ${JIOVERSION}: ${EXTERNALDIR}/URI.js \
${SRCDIR}/jio.js
\
${EXTERNALDIR}/rusha.js
\
${SRCDIR}/jio.storage/replicatestorage.js
\
${SRCDIR}/jio.storage/fallbackstorage.js
\
${SRCDIR}/jio.storage/shastorage.js
\
${SRCDIR}/jio.storage/uuidstorage.js
\
${SRCDIR}/jio.storage/memorystorage.js
\
...
...
@@ -179,6 +180,7 @@ ${JIONODEVERSION}: ${SRCDIR}/node/jio-start.js \
${SRCDIR}/jio.js
\
${SRCDIR}/node/jio.js
\
${SRCDIR}/jio.storage/replicatestorage.js
\
${SRCDIR}/jio.storage/fallbackstorage.js
\
${SRCDIR}/jio.storage/shastorage.js
\
${SRCDIR}/jio.storage/uuidstorage.js
\
${SRCDIR}/jio.storage/memorystorage.js
\
...
...
src/jio.storage/fallbackstorage.js
0 → 100644
View file @
ef27c6fd
/*
* JIO extension for resource replication.
* Copyright (C) 2021 Nexedi SA
*
* This program is free software: you can Use, Study, Modify and Redistribute
* it under the terms of the GNU General Public License version 3, or (at your
* option) any later version, as published by the Free Software Foundation.
*
* You can also Link and Combine this program with other software covered by
* the terms of any of the Free Software licenses or any of the Open Source
* Initiative approved licenses and Convey the resulting work. Corresponding
* source of such a combination shall include the source code for all other
* software used.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See COPYING file for full licensing terms.
* See https://www.nexedi.com/licensing for rationale and options.
*/
/*jslint nomen: true*/
/*global jIO*/
(
function
(
jIO
)
{
"
use strict
"
;
function
FallbackStorage
(
spec
)
{
this
.
_sub_storage
=
this
.
_current_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
if
(
spec
.
hasOwnProperty
(
'
fallback_storage
'
))
{
this
.
_fallback_storage
=
jIO
.
createJIO
(
spec
.
fallback_storage
);
this
.
_checked
=
false
;
}
else
{
this
.
_checked
=
true
;
}
}
var
method_name_list
=
[
'
get
'
,
'
put
'
,
'
post
'
,
'
remove
'
,
'
buildQuery
'
,
'
getAttachment
'
,
'
putAttachment
'
,
'
allAttachments
'
,
'
repair
'
],
i
;
function
methodFallback
(
method_name
)
{
return
function
()
{
var
storage
=
this
,
queue
=
storage
.
_current_storage
[
method_name
].
apply
(
storage
.
_current_storage
,
arguments
),
argument_list
=
arguments
;
if
(
!
storage
.
_checked
)
{
queue
.
push
(
function
(
result
)
{
storage
.
_checked
=
true
;
return
result
;
},
function
(
error
)
{
storage
.
_checked
=
true
;
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
500
))
{
// If storage is not working, use fallback instead
storage
.
_current_storage
=
storage
.
_fallback_storage
;
return
storage
.
_current_storage
[
method_name
].
apply
(
storage
.
_current_storage
,
argument_list
);
}
throw
error
;
});
}
return
queue
;
};
}
for
(
i
=
0
;
i
<
method_name_list
.
length
;
i
+=
1
)
{
FallbackStorage
.
prototype
[
method_name_list
[
i
]]
=
methodFallback
(
method_name_list
[
i
]);
}
FallbackStorage
.
prototype
.
hasCapacity
=
function
hasCapacity
(
name
)
{
return
(
this
.
_sub_storage
.
hasCapacity
(
name
)
&&
this
.
_fallback_storage
.
hasCapacity
(
name
));
};
jIO
.
addStorage
(
'
fallback
'
,
FallbackStorage
);
}(
jIO
));
test/jio.storage/fallbackstorage.tests.js
0 → 100644
View file @
ef27c6fd
This diff is collapsed.
Click to expand it.
test/tests.html
View file @
ef27c6fd
...
...
@@ -64,6 +64,7 @@ See https://www.nexedi.com/licensing for rationale and options.
<script
src=
"jio.storage/replicatestorage_repairattachment.tests.js"
></script>
<script
src=
"jio.storage/replicatestorage_fastrepair.tests.js"
></script>
<script
src=
"jio.storage/replicatestorage_fastrepairattachment.tests.js"
></script>
<script
src=
"jio.storage/fallbackstorage.tests.js"
></script>
<script
src=
"jio.storage/shastorage.tests.js"
></script>
<script
src=
"jio.storage/parserstorage.tests.js"
></script>
...
...
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