|
|
@ -47,6 +47,11 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => { |
|
|
|
var uploaded = [] |
|
|
|
var uploaded = [] |
|
|
|
async.eachSeries(sources, function (item, cb) { |
|
|
|
async.eachSeries(sources, function (item, cb) { |
|
|
|
swarmVerifiedPublish(item.content, item.hash, (error, result) => { |
|
|
|
swarmVerifiedPublish(item.content, item.hash, (error, result) => { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
item.hash = result.url.match('bzz-raw://(.+)')[1] |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
item.hash = '<Metadata inconsistency> - ' + item.fileName |
|
|
|
|
|
|
|
} |
|
|
|
if (!error && swarmVerifiedPublishCallBack) swarmVerifiedPublishCallBack(item) |
|
|
|
if (!error && swarmVerifiedPublishCallBack) swarmVerifiedPublishCallBack(item) |
|
|
|
item.output = result |
|
|
|
item.output = result |
|
|
|
uploaded.push(item) |
|
|
|
uploaded.push(item) |
|
|
@ -55,10 +60,16 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => { |
|
|
|
cb(error) |
|
|
|
cb(error) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, () => { |
|
|
|
}, () => { |
|
|
|
swarmVerifiedPublish(JSON.stringify(metadata), '', (error, result) => { |
|
|
|
const metadataContent = JSON.stringify(metadata) |
|
|
|
|
|
|
|
swarmVerifiedPublish(metadataContent, '', (error, result) => { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
contract.metadataHash = result.url.match('bzz-raw://(.+)')[1] |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
contract.metadataHash = '<Metadata inconsistency> - metadata.json' |
|
|
|
|
|
|
|
} |
|
|
|
if (!error && swarmVerifiedPublishCallBack) { |
|
|
|
if (!error && swarmVerifiedPublishCallBack) { |
|
|
|
swarmVerifiedPublishCallBack({ |
|
|
|
swarmVerifiedPublishCallBack({ |
|
|
|
content: contract.metadata, |
|
|
|
content: metadataContent, |
|
|
|
hash: contract.metadataHash |
|
|
|
hash: contract.metadataHash |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|