Skip to content

Commit

Permalink
meta2: fix WORM mode when versioning is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fvennetier committed Mar 6, 2018
1 parent 5d69aa7 commit ebc33be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions meta2v2/meta2_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,9 +1481,12 @@ meta2_backend_generate_beans(struct meta2_backend_s *m2b,
* This call may return an open database. */
m2b_get_prepare_data(m2b, url, &pdata, &sq3);

if ((m2b->flag_precheck_on_generate &&
VERSIONS_DISABLED(pdata.max_versions)) ||
(oio_ns_mode_worm && !oio_ext_is_admin())) {
gboolean must_check_alias = m2b->flag_precheck_on_generate && (
VERSIONS_DISABLED(pdata.max_versions) ||
(VERSIONS_SUSPENDED(pdata.max_versions) &&
oio_ns_mode_worm &&
!oio_ext_is_admin()));
if (must_check_alias) {
err = m2b_open_if_needed(m2b, url,
_mode_masterslave(0)|M2V2_OPEN_ENABLED, &sq3);
if (!err) {
Expand Down
9 changes: 5 additions & 4 deletions meta2v2/meta2_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1522,10 +1522,6 @@ GError* m2db_put_alias(struct m2db_put_args_s *args, GSList *beans,

/* Check the operation respects the rules of versioning for the container */
if (latest) {
if (args->worm_mode) {
err = NEWERROR(CODE_CONTENT_EXISTS, "NS wormed! Cannot overwrite.");
}

if (VERSIONS_DISABLED(max_versions)) {
if (ALIASES_get_deleted(latest) || ALIASES_get_version(latest) > 0) {
GRID_DEBUG("Versioning DISABLED but clues of SUSPENDED");
Expand All @@ -1536,6 +1532,11 @@ GError* m2db_put_alias(struct m2db_put_args_s *args, GSList *beans,
}
else if (VERSIONS_SUSPENDED(max_versions)) {
suspended:
if (args->worm_mode) {
err = NEWERROR(CODE_CONTENT_EXISTS,
"NS wormed! Cannot overwrite.");
}

// JFS: do not alter the size to manage the alias being removed,
// this will be done by the real purge of the latest.
purge_latest = TRUE;
Expand Down

0 comments on commit ebc33be

Please sign in to comment.