i have case once user download file deleting directory, once new message comes in still trying append file not exist , how can check if obj.file exist append ?
server.js
recordlogs: function (obj) { var path = './app/records/templogs' var fileappend = path + '/'+ obj.file; console.log('data recoring', obj.data); fs.readdir(path, function(err, items) { items.foreach(function(file){ if(obj.file === file){ fs.appendfile(fileappend, obj.data, null, 'utf8', function (err) { if (err) throw err; }); console.log('filename in records',obj.file); } }); }); }
Comments
Post a Comment