azurite
Version:
An open source Azure Storage API compatible server
49 lines • 2.15 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("../generated/artifacts/models");
/**
* TODO: Update expire blob lease status to available on write blob operations.
*
* Need run the function on: PutBlob, SetBlobMetadata, SetBlobProperties,
* DeleteBlob, PutBlock, PutBlockList, PutPage, AppendBlock, CopyBlob(dest)
*
* @export
* @class BlobWriteLeaseSyncer
* @implements {ILeaseSyncer<BlobModel>}
*/
class BlobWriteLeaseSyncer {
constructor(blob) {
this.blob = blob;
}
sync(lease) {
this.blob.leaseId = lease.leaseId;
this.blob.leaseExpireTime = lease.leaseExpireTime;
this.blob.leaseDurationSeconds = lease.leaseDurationSeconds;
this.blob.leaseBreakTime = lease.leaseBreakTime;
this.blob.properties.leaseDuration = lease.leaseDurationType;
this.blob.properties.leaseState = lease.leaseState;
this.blob.properties.leaseStatus = lease.leaseStatus;
if (lease.leaseState === models_1.LeaseStateType.Expired ||
lease.leaseState === models_1.LeaseStateType.Broken) {
this.blob.properties.leaseState = models_1.LeaseStateType.Available;
this.blob.properties.leaseStatus = models_1.LeaseStatusType.Unlocked;
this.blob.properties.leaseDuration = undefined;
this.blob.leaseDurationSeconds = undefined;
this.blob.leaseId = undefined;
this.blob.leaseExpireTime = undefined;
this.blob.leaseBreakTime = undefined;
}
else {
this.blob.leaseId = lease.leaseId;
this.blob.leaseExpireTime = lease.leaseExpireTime;
this.blob.leaseDurationSeconds = lease.leaseDurationSeconds;
this.blob.leaseBreakTime = lease.leaseBreakTime;
this.blob.properties.leaseDuration = lease.leaseDurationType;
this.blob.properties.leaseState = lease.leaseState;
this.blob.properties.leaseStatus = lease.leaseStatus;
}
return this.blob;
}
}
exports.default = BlobWriteLeaseSyncer;
//# sourceMappingURL=BlobWriteLeaseSyncer.js.map