function delImg(filePath) { if(filePath) { fs.access(con.filePath+filePath.replace(/\//g,path.sep),fs.constants.F_OK,function (err) { if(!err) { fs.unlink(con.filePath+filePath); } }) } }
/** * Deletes a file in the current directory */ function deleteFileInCurrentDir(file, callback) { fs.unlink(path.join(__dirname, file), callback); }
output.on('close', function() { rm(path.join(con.filePath,"temp",name),{},function (err) { }); res.download(pathName,req.obj.name+".zip",function (err) { if(!err) { obj.removeAsync(); fs.access(pathName,fs.constants.F_OK,function (err) { if(!err) { fs.unlink(pathName); } }) } }); });
function getPipInstaller() { // install pip return new Promise((resolve, reject) => { const pipFilePath = path.join(__dirname, "get-pip.py"); if (fs.existsSync(pipFilePath)) return resolve(pipFilePath); const file = fs.createWriteStream(pipFilePath); const request = https.get(pipUrl, function(response) { response.pipe(file); file.on("finish", function() { file.close(() => { resolve(pipFilePath); }); }); file.on("error", function(err) { fs.unlink(pipFilePath); reject(err); }); }); }); }
deleteFile(filename) { fs.unlink(this.getTempPath(filename)); }
fs.unlink(filePath, () => {})
async function cleanOldMessages(messageObjects, ttl) { const olderThen = Date.now() - ttl; await Promise.all( messageObjects .filter(obj => (obj.time / 1000) < olderThen) .map(obj => unlink(obj.path).catch(() => null)) ); }
fs.readdir(dir, function(err, files) { if(err && typeof failSilent === 'boolean' && !failSilent) return clbk(err); if(typeof failSilent === 'function') clbk = failSilent; (function rmFile(err){ if (err) return clbk(err); var filename = files.shift(); if (filename === null || typeof filename == 'undefined') return fs.rmdir(dir, clbk); var file = dir+'/'+filename; fs.lstat(file, function(err, stat){ if (err) return clbk(err); if (stat.isDirectory()) rmdirRecursive(file, rmFile); else fs.unlink(file, rmFile); }); })(); });
function removeModel(req, res, next) { logger.winston.info('Model.removeModel'); db.run('delete from models where model_id = ?', req.query.model_id, function(err) { if (err) { logger.winston.error("Error removing the record"); } else { if (req.query.local_path && req.query.local_path != "Manually Added") { fs.unlink(req.query.local_path, (err) => { if (err) { logger.winston.info(err) return } }) } res.status(200).json({ status: 'success', message: 'Removed' }); } }); }
callback(env); }).catch(function(err){ fs.unlink(envPath);
fs.unlink(filePath, err => { if (err) { console.log("error deleting file " + err);
/** * Deletes a file. * @param {string} file - Path to the file to delete. * @param {Function} callback */ const deleteFile = (file, callback) => fs.unlink(file, callback)
function cleanup (callback) { fs.unlink(constants.infoFile, function onUnlink () { /** ignore any error */ cleanImages(callback) }) }
function getPipInstaller() { // install pip return new Promise((resolve, reject) => { const pipFilePath = path.join(__dirname, "get-pip.py"); if (fs.existsSync(pipFilePath)) return resolve(pipFilePath); const file = fs.createWriteStream(pipFilePath); const request = https.get(pipUrl, function(response) { response.pipe(file); file.on("finish", function() { file.close(() => { resolve(pipFilePath); }); }); file.on("error", function(err) { fs.unlink(pipFilePath); reject(err); }); }); }); }
function deleteFile(filename) { fs.unlink(filename); }