Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('Size:', size);
const stream = fs.createReadStream(file);
const [sha1hash, sha256hash] = await Promise.all([hashStream('sha1', stream), hashStream('sha256', stream)]);
console.log('SHA1:', sha1hash);
console.log('SHA256:', sha256hash);
const blobName = commit + '/' + name;
const storageAccount = process.env['AZURE_STORAGE_ACCOUNT_2']!;
const blobService = azure.createBlobService(storageAccount, process.env['AZURE_STORAGE_ACCESS_KEY_2']!)
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
const mooncakeBlobService = azure.createBlobService(storageAccount, process.env['MOONCAKE_STORAGE_ACCESS_KEY']!, `${storageAccount}.blob.core.chinacloudapi.cn`)
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
// mooncake is fussy and far away, this is needed!
mooncakeBlobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000;
await Promise.all([
assertContainer(blobService, quality),
assertContainer(mooncakeBlobService, quality)
]);
const [blobExists, moooncakeBlobExists] = await Promise.all([
doesAssetExist(blobService, quality, blobName),
doesAssetExist(mooncakeBlobService, quality, blobName)
]);
const promises: Array> = [];
const t = require('tape');
const azure = require('azure-storage');
const sc = require('skale').context();
//const skip = process.env.CI || (process.env.AZURE_STORAGE_CONNECTION_STRING ? false : true);
const skip = true;
const retry = new azure.ExponentialRetryPolicyFilter();
const az = skip ? null : azure.createBlobService().withFilter(retry);
const savedir = 'wasb://skalejs/save';
t.test('save azure', {skip: skip}, function (t) {
t.plan(3);
deleteAzureDir('save', '', function (err) {
t.ok(!err, 'delete previous saved test data');
sc.range(10)
.save(savedir, function (err) {
t.ok(!err, 'save returns no error');
sc.textFile(savedir + '/')
.map(a => JSON.parse(a))
.collect(function (err, res) {
t.deepEqual(res, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 'saved content is correct');
});
static createTableService(account, key) {
factoryLogger.info(`creating table service`);
const retryOperations = new AzureStorage.ExponentialRetryPolicyFilter();
return AzureStorage.createTableService(account, key).withFilter(retryOperations);
}
static createAzureDeltaStore(inner, name = null, options = {}) {
name = name || config.get('CRAWLER_DELTA_STORAGE_NAME') || `${config.get('CRAWLER_STORAGE_NAME')}-log`;
const account = config.get('CRAWLER_DELTA_STORAGE_ACCOUNT') || config.get('CRAWLER_STORAGE_ACCOUNT');
const key = config.get('CRAWLER_DELTA_STORAGE_KEY') || config.get('CRAWLER_STORAGE_KEY');
logger.info('creating delta store', {name: name, account: account});
const retryOperations = new AzureStorage.ExponentialRetryPolicyFilter();
const blobService = AzureStorage.createBlobService(account, key).withFilter(retryOperations);
return new DeltaStore(inner, blobService, name, options);
}
function queueSigningRequest(quality: string, commit: string): Promise {
const retryOperations = new azure.ExponentialRetryPolicyFilter();
const queueSvc = azure
.createQueueService(process.env['AZURE_STORAGE_ACCOUNT_2'], process.env['AZURE_STORAGE_ACCESS_KEY_2'])
.withFilter(retryOperations);
queueSvc.messageEncoder = new azure.QueueMessageEncoder.TextBase64QueueMessageEncoder();
const message = `${quality}/${commit}`;
return new Promise((c, e) => queueSvc.createMessage('sign-darwin', message, err => err ? e(err) : c()));
}
} else {
createFolderAndClearPromise.then(function () {
return uploadFileToAzureCdn(blobService, options, loggerCallback, destFileName, sourceFile, metadata)
}).then(function () {
eachCallback();
}).catch(function (error) {
eachCallback(error);
});
}
}, function (err) {
cb(err);
});
};
module.exports.filters = {
ExponentialRetryPolicyFilter: new azure.ExponentialRetryPolicyFilter(),
LinearRetryPolicyFilter : new azure.LinearRetryPolicyFilter(),
RetryPolicyFilter : new azure.RetryPolicyFilter()
}
function createTableService(account, key) {
factoryLogger.info(`creating table service`);
const retryOperations = new AzureStorage.ExponentialRetryPolicyFilter();
return AzureStorage.createTableService(account, key).withFilter(retryOperations);
}
static createBlobService(account, key) {
factoryLogger.info(`creating blob service`);
const retryOperations = new AzureStorage.ExponentialRetryPolicyFilter();
return AzureStorage.createBlobService(account, key).withFilter(retryOperations);
}
function queueSigningRequest(quality, commit) {
var retryOperations = new azure.ExponentialRetryPolicyFilter();
var queueSvc = azure
.createQueueService(process.env['AZURE_STORAGE_ACCOUNT_2'], process.env['AZURE_STORAGE_ACCESS_KEY_2'])
.withFilter(retryOperations);
queueSvc.messageEncoder = new azure.QueueMessageEncoder.TextBase64QueueMessageEncoder();
var message = quality + "/" + commit;
return new Promise(function (c, e) { return queueSvc.createMessage('sign-darwin', message, function (err) { return err ? e(err) : c(); }); });
}
function isBuildSigned(quality, commit) {