azurite
Version:
An open source Azure Storage API compatible server
33 lines • 1.28 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ConditionResourceAdapter {
constructor(resource) {
if (resource === undefined ||
resource === null ||
resource.isCommitted === false // Treat uncommitted blob as nonexistent resource
) {
this.exist = false;
this.etag = "NONEXISTENT_RESOURCE_ETAG";
this.lastModified = undefined;
return;
}
this.exist = true;
this.etag = resource.properties.etag;
if (this.etag.length < 3) {
throw new Error(`ConditionResourceAdapter::constructor() Invalid etag ${this.etag}.`);
}
if (this.etag.startsWith('"') && this.etag.endsWith('"')) {
this.etag = this.etag.substring(1, this.etag.length - 1);
}
this.lastModified = new Date(resource.properties.lastModified);
this.lastModified.setMilliseconds(0); // Precision to seconds
const blobItem = resource;
this.blobItemWithTags = {
name: blobItem.name,
containerName: blobItem.containerName,
tags: blobItem.blobTags
};
}
}
exports.default = ConditionResourceAdapter;
//# sourceMappingURL=ConditionResourceAdapter.js.map