Comparing version 0.6.12 to 0.6.13
@@ -356,12 +356,2 @@ 'use strict'; | ||
// Writing multiple blocks to one blob | ||
const combinedStream = CombinedStream.create(); | ||
for (const blockName of blockPaths) { | ||
combinedStream.append(fs.createReadStream(blockName)); | ||
} | ||
const blobPath = path.join(env.localStoragePath, containerName, blob.name); | ||
// FIXME: The entire REST call may return before the file has been entirely written to disk! | ||
combinedStream.pipe(fs.createWriteStream(blobPath)); | ||
// Updating properties of blob | ||
@@ -391,21 +381,46 @@ const coll = this.db.getCollection(containerName); | ||
} | ||
// Set Blocks in DB to committed = true, delete blocks not in BlockList | ||
const promises = []; | ||
const collCommits = this.db.getCollection(StorageTables.Commits); | ||
const blocks = collCommits.chain() | ||
.find({ parent: `${containerName}-${blob.name}` }) | ||
.data(); | ||
for (const block of blocks) { | ||
if (blockList.map((e) => { return e.id }).indexOf(block.blockId) !== -1) { | ||
block.committed = true; | ||
collCommits.update(block); | ||
} else { | ||
collCommits.remove(block); | ||
promises.push(fs.removeAsync(path.join(env.commitsPath, block.name))); | ||
} | ||
// Writing multiple blocks to one blob | ||
const combinedStream = CombinedStream.create(); | ||
for (const blockName of blockPaths) { | ||
combinedStream.append(fs.createReadStream(blockName)); | ||
} | ||
return BbPromise.all(promises) | ||
.then(() => { | ||
return response; | ||
}); | ||
const blobPath = path.join(env.localStoragePath, containerName, blob.name); | ||
return new BbPromise((resolve, reject) => { | ||
const destinationStream = fs.createWriteStream(blobPath); | ||
destinationStream | ||
.on('error', (e) => { | ||
reject(e); | ||
}) | ||
.on('finish', () => { | ||
let totalSize = 0; | ||
// Set Blocks in DB to committed = true, delete blocks not in BlockList | ||
const promises = []; | ||
const collCommits = this.db.getCollection(StorageTables.Commits); | ||
const blocks = collCommits.chain() | ||
.find({ parent: `${containerName}-${blob.name}` }) | ||
.data(); | ||
for (const block of blocks) { | ||
if (blockList.map((e) => { return e.id }).indexOf(block.blockId) !== -1) { | ||
block.committed = true; | ||
totalSize += block.size; | ||
collCommits.update(block); | ||
} else { | ||
collCommits.remove(block); | ||
promises.push(fs.removeAsync(path.join(env.commitsPath, block.name))); | ||
} | ||
} | ||
return BbPromise.all(promises) | ||
.then(() => { | ||
const updateBlob = coll.chain() | ||
.find({ 'name': { '$eq': blob.name } }) | ||
.data()[0]; | ||
updateBlob.size = totalSize; | ||
coll.update(updateBlob); | ||
resolve(response); | ||
}); | ||
}); | ||
combinedStream.pipe(destinationStream); | ||
}); | ||
}); | ||
@@ -642,3 +657,2 @@ } | ||
updatedBlob.size = fs.statSync(blobPath).size; | ||
updatedBlob.httpProps['Content-Length'] = updatedBlob.size; | ||
updatedBlob.httpProps['x-ms-blob-sequence-number'] = updatedBlob.meta.revision; | ||
@@ -645,0 +659,0 @@ coll.update(updatedBlob); |
{ | ||
"name": "azurite", | ||
"version": "0.6.12", | ||
"version": "0.6.13", | ||
"description": "A lightweight server clone of Azure Blob Storage that simulates most of the commands supported by it with minimal dependencies.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130269
2834