diff --git a/lib/classes/read-file.js b/lib/classes/read-file.js index 607c5fe8..54bcf530 100644 --- a/lib/classes/read-file.js +++ b/lib/classes/read-file.js @@ -1,11 +1,12 @@ import { isReadableStream } from "../stream.js"; const ReadFile = class ReadFile { - constructor({ mimeType = "", etag = "" } = {}) { + constructor({ mimeType = "", etag = "", generation = "" } = {}) { this._mimeType = mimeType; // @ts-ignore this._stream = undefined; this._etag = etag; + this._generation = generation; } get mimeType() { @@ -27,6 +28,15 @@ const ReadFile = class ReadFile { return this._etag; } + /** + * An opaque version token captured at read time. Pass this back to + * sink.write() as options.ifGenerationMatch to perform a compare-and-swap + * write that fails if another writer has modified the file in the meantime. + */ + get generation() { + return this._generation; + } + get [Symbol.toStringTag]() { return "ReadFile"; }