kopia lustrzana https://gitlab.com/rysiekpl/libresilient
rodzic
65708a129d
commit
40e2c9ddef
|
@ -205,7 +205,7 @@
|
|||
|
||||
console.log("Adding to IPFS...")
|
||||
console.log("+-- number of resources:", resources.length)
|
||||
var ipfs_addresses = {};
|
||||
var ipfs_addresses = new Map();
|
||||
|
||||
resources.forEach(function(res){
|
||||
console.log(" +-- handling internal resource:", res)
|
||||
|
@ -217,10 +217,10 @@
|
|||
// res holds the full URL
|
||||
// what we need in ipfs_addresses is in fact the absolute path (no domain, no scheme)
|
||||
var abs_path = res.replace(window.location.origin, '')
|
||||
ipfs_addresses[abs_path] = '/ipfs/' + result.cid.string
|
||||
console.log("Added to IPFS: " + abs_path + ' as ' + ipfs_addresses[abs_path])
|
||||
ipfs_addresses.set(abs_path, '/ipfs/' + result.cid.string)
|
||||
console.log("Added to IPFS: " + abs_path + ' as ' + ipfs_addresses.get(abs_path))
|
||||
// if we seem to have all we need, resolve!
|
||||
if (Object.keys(ipfs_addresses).length === resources.length) resolve(ipfs_addresses);
|
||||
if (ipfs_addresses.size === resources.length) resolve(ipfs_addresses);
|
||||
})
|
||||
|
||||
});
|
||||
|
@ -254,10 +254,10 @@
|
|||
console.log('Checking IPFS content against a gateway...')
|
||||
console.log('+-- gateway in use: ' + config.ipfsGateway)
|
||||
// get the list of IPFS addresses
|
||||
var updatedPaths = Object.values(ipfs_addresses)
|
||||
for (path in ipfs_addresses) {
|
||||
var updatedPaths = Array.from(ipfs_addresses.values())
|
||||
for (const path of ipfs_addresses.keys()) {
|
||||
// start the fetch
|
||||
fetch(config.ipfsGateway + ipfs_addresses[path])
|
||||
fetch(config.ipfsGateway + ipfs_addresses.get(path))
|
||||
.then((response) => {
|
||||
ipfsaddr = response.url.replace(config.ipfsGateway, '')
|
||||
if (response.ok) {
|
||||
|
|
Ładowanie…
Reference in New Issue