spec-3nweb-server 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -153,10 +153,12 @@ class Store extends user_files_1.UserFiles {
153
153
  await spaceTracker.change(this, byteLen);
154
154
  }
155
155
  const params = {
156
- isNewObj: opts.create,
157
156
  version: opts.ver,
158
157
  baseVersion: (diff ? diff.baseVersion : undefined)
159
158
  };
159
+ if (opts.ver === 1) {
160
+ params.isNewObj = true;
161
+ }
160
162
  const trans = await this.transactions.startNew(objId, params);
161
163
  let file;
162
164
  try {
@@ -653,7 +655,7 @@ class ObjTransactions {
653
655
  if (status.state !== 'current') {
654
656
  throw exports.SC.OBJ_UNKNOWN;
655
657
  }
656
- else if (trans.version <= status.currentVersion) {
658
+ else if (trans.version !== (status.currentVersion + 1)) {
657
659
  throw makeMismatchedObjVerException(status.currentVersion);
658
660
  }
659
661
  }
@@ -53,7 +53,7 @@ function saveCurrentObj(root, saveObjFunc, chunkLimit) {
53
53
  const { fstReq, sndReq } = opts;
54
54
  let diff;
55
55
  if (fstReq) {
56
- if (fstReq.create && objId) {
56
+ if (!root && objId) {
57
57
  if (!buffer_utils_1.base64urlSafe.allCharsFromAlphabet(objId)) {
58
58
  return replyToMalformed(req, "Bad object id", res);
59
59
  }
@@ -171,7 +171,6 @@ function extractQueryOptions(req) {
171
171
  // this is the first request
172
172
  // query fields are string or undefined, yet, type info helps the show
173
173
  const query = req.query;
174
- const create = (query.create === 'true');
175
174
  const ver = parseInt(query.ver);
176
175
  if (isNaN(ver) || (ver < 1)) {
177
176
  return;
@@ -187,7 +186,7 @@ function extractQueryOptions(req) {
187
186
  return;
188
187
  }
189
188
  const last = (query.last === 'true');
190
- return { fstReq: { diff, header, last, ver, create } };
189
+ return { fstReq: { diff, header, last, ver } };
191
190
  }
192
191
  }
193
192
  function getContentLenOrSendError(req, res, maxChunkSize) {
@@ -66,10 +66,6 @@ export interface GetObjQueryOpts {
66
66
  ver?: number;
67
67
  }
68
68
  export interface PutObjFirstQueryOpts {
69
- /**
70
- * This is a flag to indicate that new object should be created.
71
- */
72
- create?: boolean;
73
69
  /**
74
70
  * This parameter is object's new version.
75
71
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",