Skip to content

Commit

Permalink
bf(ARSN-361): Handle infinite versionID correctly on version specific…
Browse files Browse the repository at this point in the history
… PUT for file MD backend
  • Loading branch information
tmacro committed Aug 11, 2023
1 parent 89e5f7d commit e140b63
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/versioning/VersioningRequestProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import errors, { ArsenalError } from '../errors';
import { Version } from './Version';
import { generateVersionId as genVID } from './VersionID';
import { generateVersionId as genVID, getInfVid } from './VersionID';
import WriteCache from './WriteCache';
import WriteGatheringManager from './WriteGatheringManager';

Expand Down Expand Up @@ -381,10 +381,13 @@ export default class VersioningRequestProcessor {
const versionKey = formatVersionKey(request.key, versionId);
const ops = [{ key: versionKey, value: request.value }];
if (data === undefined ||
(Version.from(data).getVersionId() ?? '') >= versionId) {
(Version.from(data).getVersionId() ?? '') >= versionId ||
(versionId === getInfVid(this.replicationGroupId) && !Version.from(data).getVersionId())) {
// master does not exist or is not newer than put
// version and needs to be updated as well.
// Note that older versions have a greater version ID.
// If an infinite version ID is used and the master does not have a versionId,
// then the master is updated.
ops.push({ key: request.key, value: request.value });
}
return callback(null, ops, versionId);
Expand Down

0 comments on commit e140b63

Please sign in to comment.