Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const deleteOldNeutrino = async function(walletDir: string) {
const d = walletDir + "/data/chain/bitcoin/testnet/";
let contents = await RNFS.readdir(d);
contents = contents.filter(c => c != "wallet.db");
for (let c of contents) {
try {
await RNFS.unlink(d + c);
} catch (err) {
console.error("couldn't delete old neutrino", err);
}
}
};
async keys() {
return (await RNFS.readdir(this._mapDir)).map(fileName => fileName.split('.', 2)[0]);
}
async size() {
return (await RNFS.readdir(this._mapDir)).length;
}
async _getFileForKey(key) {
const dir = await RNFS.readdir(this._mapDir);
return dir.find(v => v.startsWith(`${key}.`));
}
function _cleanLogs(logPath, amountOfDaysStored = 3) {
let allowedLogFiles = {};
for (let i = 0; i < amountOfDaysStored; i++) {
let timestamp = new Date().valueOf() - i*86400000;
allowedLogFiles[getFilename(timestamp)] = true;
}
let flagForRemoval = [];
RNFS.readdir(logPath)
.then((files) => {
for (let i = 0; i < files.length; i++) {
if (files[i].substr(0,14) === "ConsumerAppLog" && allowedLogFiles[files[i]] !== true) {
flagForRemoval.push(files[i]);
}
}
for (let i = 0; i < flagForRemoval.length; i++) {
FileUtil.safeDeleteFile(logPath + "/" + flagForRemoval[i]).catch(()=>{});
}
})
.catch((err) => {
});
}