Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
fixes #86, fixes #87
Browse files Browse the repository at this point in the history
  • Loading branch information
arafato committed Oct 10, 2017
1 parent 32812d8 commit 9e47dac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lib/StorageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class StorageManager {
condition.push({
'name': { '$contains': query.prefix }
});
condition.push({
'parentId': { '$eq': undefined } // blocks should never be part of the listing
});

if (query.include !== 'snapshots') {
condition.push({
'snapshot': { '$eq': false }
Expand All @@ -169,7 +173,7 @@ class StorageManager {
condition.push({
'committed': { '$eq': true }
});
}
}
const coll = this.db.getCollection(request.containerName);
const blobs = coll.chain()
.find({
Expand Down Expand Up @@ -198,6 +202,7 @@ class StorageManager {
delete parentBlobRequest.parentId;
delete parentBlobRequest.blockId;
parentBlobRequest.commit = false;
parentBlobRequest.body = undefined;
this._createOrUpdateBlob(coll, parentBlobRequest);
}
// Storing block information in DB.
Expand Down
2 changes: 1 addition & 1 deletion lib/model/AzuriteBlobRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AzuriteBlobRequest extends AzuriteRequest {

calculateContentMd5() {
if (!this.body) {
throw new InternalAzuriteError('Request: MD5 calculation without initialized body.');
return undefined;
}
return crypto.createHash('md5')
.update(this.body)
Expand Down
2 changes: 1 addition & 1 deletion lib/model/BlobProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BlobProxy extends StorageEntityProxy {
* @memberof BlobProxy
*/
updateETag() {
const etagValue = etag(`${this.lastModified()}${JSON.stringify(this.original.metaProps)}${this.original.name}${this.containerName}${this.original.meta.revision}`);
const etagValue = etag(`${this.lastModified()}${JSON.stringify(this.original.metaProps)}${this.original.id}${this.original.meta.revision}`);
this.original.etag = `${etagValue}`;
return this.original.etag;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/model/StorageEntityGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class StorageEntityGenerator {
entity.committed = request.commit; // this is true per default
entity.md5 = request.httpProps[N.CONTENT_MD5] || request.calculateContentMd5();
entity.size = request.body ? request.body.length : 0;
entity.etag = etag(`${Date.parse(new Date())}${JSON.stringify(entity.metaProps)}${request.blobName}${request.containerName}`);
entity.etag = etag(`${Date.parse(new Date())}${JSON.stringify(entity.metaProps)}${request.id}`);
// The following attributes are deleted if they are undefined
entity.cacheControl = request.httpProps[N.CACHE_CONTROL]; entity.cacheControl === undefined ? delete entity.cacheControl : (() => {/*NOOP*/ });
entity.contentType = request.httpProps[N.CONTENT_TYPE]; entity.contentType === undefined ? delete entity.contentType : (() => {/*NOOP*/ });
Expand All @@ -61,14 +61,14 @@ class StorageEntityGenerator {
delete entity.md5;
}
// Specific to Block Blobs that are potentially part of a commit
if (request.entityType === EntityType.BlockBlob && request.blockId !== undefined) {
else if (request.entityType === EntityType.BlockBlob && request.blockId !== undefined) {
entity.blockId = request.blockId;
// entity.parent = `${request.containerName}-${request.blobName}`;
// entity.name = `${entity.parent}-${entity.blockId}`;
entity.committed = false;
}
// Specific to Page Blobs
if (request.entityType === EntityType.PageBlob) {
else if (request.entityType === EntityType.PageBlob) {
entity.size = request.httpProps[N.BLOB_CONTENT_LENGTH];
entity.sequenceNumber = 0;
// MD5 calculation of a page blob seems to be wrong, thus deleting it for now...
Expand Down

0 comments on commit 9e47dac

Please sign in to comment.