Skip to content

Commit

Permalink
actually, default to not using preconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
sanoel committed Jun 5, 2024
1 parent e52f285 commit a8759f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export interface PUTRequest {
contentType?: string;
/** If-Match */
etagIfMatch?: string | readonly string[];
ignoreEtagIfMatch?: boolean;
useEtags?: boolean;
tree?: Tree;
timeout?: number;
headers?: Record<string, string>;
Expand Down Expand Up @@ -666,7 +666,7 @@ export class OADAClient {
const pathArray = toArrayPath(request.path);

if (request.tree) {
await this.#retryEnsureTree(request.tree, pathArray, request.ignoreEtagIfMatch);
await this.#retryEnsureTree(request.tree, pathArray, request.useEtags);
}

const contentType = await this.#guessContentType(request, pathArray);
Expand Down Expand Up @@ -868,7 +868,7 @@ export class OADAClient {
return body; // Return object at "path"
}

async #ensureTree(tree: Tree, pathArray: readonly string[], ignoreEtagIfMatch?: boolean) {
async #ensureTree(tree: Tree, pathArray: readonly string[], useEtags?: boolean) {
// Link object (eventually substituted by an actual link object)
// eslint-disable-next-line unicorn/no-null
let linkObject: Json = null;
Expand Down Expand Up @@ -906,7 +906,7 @@ export class OADAClient {
contentType,
data: linkObject,
// Ensure the resource has not been modified (opportunistic lock)
...(ignoreEtagIfMatch && {
...(useEtags && {
etagIfMatch: resourceCheckResult.etag,
})
});
Expand Down Expand Up @@ -970,7 +970,7 @@ export class OADAClient {
return 'application/json';
}

async #retryEnsureTree(tree: Tree, pathArray: readonly string[], ignoreEtagIfMatch?: boolean) {
async #retryEnsureTree(tree: Tree, pathArray: readonly string[], useEtags?: boolean) {
// Retry on certain errors
const CODES = new Set(['412', '422'] as const);
const MAX_RETRIES = 5;
Expand All @@ -979,7 +979,7 @@ export class OADAClient {
length: MAX_RETRIES - 1,
}).keys()) {
try {
await this.#ensureTree(tree, pathArray, ignoreEtagIfMatch);
await this.#ensureTree(tree, pathArray, useEtags);

return;
} catch (cError: unknown) {
Expand All @@ -996,7 +996,7 @@ export class OADAClient {
}
}

await this.#ensureTree(tree, pathArray, ignoreEtagIfMatch);
await this.#ensureTree(tree, pathArray, useEtags);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@
"deep-clone@^4.0.0": "patch:deep-clone@npm%3A4.0.0#./.yarn/patches/deep-clone-npm-4.0.0-eee1a48c85.patch",
"xksuid": "https://github.com/aultac/xksuid.git#commit=22a21eb01331191feb62ea0a4e67d96d2e80f396"
}
}
}

0 comments on commit a8759f2

Please sign in to comment.