Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async remove(url) {
// remove from library
await this.ready;
const archiveInfo = await storage.getItem(url);
if (!archiveInfo) {
throw new Error('Archive not in library');
}
// close archive
await this.close(url);
await storage.removeItem(url);
return archiveInfo;
}
const loadLibrary = library.map(async ({ url }) => {
try {
const address = await dns.resolveName(url);
const dat = await this.node.getDat(address, datOpts);
await dat.ready;
const archive = createDatArchive(dat.drive);
this.archives.set(address, archive);
} catch (e) {
// failed to load archive, remove from library
await storage.removeItem(url);
}
});
return new Promise((resolve) => {
PersistStorage.removeItem(key)
.then(() => resolve(true))
.catch(() => resolve(false));
});
} catch(error) {
exports.member_delete = async function(req, res) {
const navigate =
{
active: 'networks',
whence: ''
}
try {
const network = await zt.network_detail(req.params.nwid);
let member = null;
let name = null;
if (req.method === 'POST') {
member = await zt.member_delete(req.params.nwid, req.params.id);
if (member.deleted) {
name = await storage.removeItem(member.id);
}
} else {
member = await zt.member_detail(req.params.nwid, req.params.id);
name = await storage.getItem(member.id);
}
if (!name) name = '';
member.name = name;
navigate.whence = '/controller/network/' + network.nwid + '/members';
res.render('member_delete', {title: 'Delete member from ' + network.name,
navigate: navigate, network: network, member: member});
} catch (err) {
res.render('member_delete', {title: 'Delete member from network', navigate: navigate,
error: 'Error resolving detail for member ' + req.params.id
+ ' of network ' + req.params.nwid + ': ' + err});
}