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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
jio
Commits
5d6e60dd
Commit
5d6e60dd
authored
Aug 22, 2017
by
Vincent Bechu
Committed by
Vincent Bechu
Aug 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[saferepairstorage] Add saferepair storage to prevent issue in replication with frozen documents
parent
bafcf854
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
+91
-0
src/jio.storage/saferepairstorage.js
src/jio.storage/saferepairstorage.js
+91
-0
No files found.
src/jio.storage/saferepairstorage.js
0 → 100644
View file @
5d6e60dd
/*jslint nomen: true*/
(
function
(
jIO
)
{
"
use strict
"
;
/**
* The jIO SafeRepairStorage extension
*
* @class SafeRepairStorage
* @constructor
*/
function
SafeRepairStorage
(
spec
)
{
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
this
.
_id_dict
=
{};
}
SafeRepairStorage
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
SafeRepairStorage
.
prototype
.
allAttachments
=
function
()
{
return
this
.
_sub_storage
.
allAttachments
.
apply
(
this
.
_sub_storage
,
arguments
);
};
SafeRepairStorage
.
prototype
.
post
=
function
()
{
return
this
.
_sub_storage
.
post
.
apply
(
this
.
_sub_storage
,
arguments
);
};
SafeRepairStorage
.
prototype
.
put
=
function
(
id
,
doc
)
{
var
storage
=
this
;
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
)
.
push
(
undefined
,
function
(
error
)
{
if
(
error
instanceof
jIO
.
util
.
jIOError
&&
error
.
status_code
===
403
)
{
if
(
storage
.
_id_dict
[
id
])
{
return
storage
.
_sub_storage
.
put
(
storage
.
_id_dict
[
id
],
doc
);
}
return
storage
.
_sub_storage
.
post
(
doc
)
.
push
(
function
(
sub_id
)
{
storage
.
_id_dict
[
id
]
=
sub_id
;
return
sub_id
;
});
}
});
};
SafeRepairStorage
.
prototype
.
remove
=
function
()
{
return
;
};
SafeRepairStorage
.
prototype
.
getAttachment
=
function
()
{
return
this
.
_sub_storage
.
getAttachment
.
apply
(
this
.
_sub_storage
,
arguments
);
};
SafeRepairStorage
.
prototype
.
putAttachment
=
function
(
id
,
attachment_id
,
attachment
)
{
var
storage
=
this
;
return
this
.
_sub_storage
.
putAttachment
.
apply
(
this
.
_sub_storage
,
arguments
)
.
push
(
undefined
,
function
(
error
)
{
if
(
error
instanceof
jIO
.
util
.
jIOError
&&
error
.
status_code
===
403
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
if
(
storage
.
_id_dict
[
id
])
{
return
storage
.
_id_dict
[
id
];
}
return
storage
.
_sub_storage
.
get
(
id
)
.
push
(
function
(
doc
)
{
return
storage
.
_sub_storage
.
post
(
doc
);
});
})
.
push
(
function
(
sub_id
)
{
storage
.
_id_dict
[
id
]
=
sub_id
;
return
storage
.
_sub_storage
.
putAttachment
(
sub_id
,
attachment_id
,
attachment
);
});
}
});
};
SafeRepairStorage
.
prototype
.
removeAttachment
=
function
()
{
return
;
};
SafeRepairStorage
.
prototype
.
repair
=
function
()
{
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
);
};
SafeRepairStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
this
.
_sub_storage
.
hasCapacity
(
name
);
};
SafeRepairStorage
.
prototype
.
buildQuery
=
function
()
{
return
this
.
_sub_storage
.
buildQuery
.
apply
(
this
.
_sub_storage
,
arguments
);
};
jIO
.
addStorage
(
'
saferepair
'
,
SafeRepairStorage
);
}(
jIO
));
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