Clean attachments sequentially

parent 55e7be0c
...@@ -69,12 +69,12 @@ class Cleaner { ...@@ -69,12 +69,12 @@ class Cleaner {
let metadata = new Metadata(); let metadata = new Metadata();
return Promise.join( return Promise.join(
metadata.delRecord(hash),
ipfs.unpin(hash) ipfs.unpin(hash)
).then(() => { ).then(() => {
logging.info(`Successfully deleted attachment ${hash}`); logging.info(`Successfully unpinned attachment ${hash}`);
}).catch((error) => { return metadata.delRecord(hash);
logging.error(error); }).then(() => {
logging.info(`Deleted metadata for ${hash}`);
}); });
} }
...@@ -102,12 +102,9 @@ class Cleaner { ...@@ -102,12 +102,9 @@ class Cleaner {
let ipfs = new Ipfs(); let ipfs = new Ipfs();
let metadata = new Metadata(); let metadata = new Metadata();
return Promise.map(list, (hash) => { return Promise.mapSeries(list, (hash) =>
return Promise.join( this.delAttachment(hash)
metadata.delRecord(hash), ).then(() => {
ipfs.unpin(hash)
);
}).then(() => {
logging.info(`Successfully deleted ${list.length} attachments`); logging.info(`Successfully deleted ${list.length} attachments`);
}); });
}).catch((error) => { }).catch((error) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment