Permalink
Browse files

use fs.appendFile

  • Loading branch information...
1 parent 8f66a9a commit 5d7a138f8d59ea0c8e11915dd9feeb3a3fc58245 @4z3 4z3 committed Jan 13, 2014
Showing with 6 additions and 12 deletions.
  1. +6 −12 lib/magnetlib.js
View
18 lib/magnetlib.js
@@ -102,18 +102,12 @@ var httpGet = exports.httpGet = function httpGet(content, callback, encoding) {
* @return data to be written
*/
var appendData = exports.appendData = function appendData(file, data) {
- Fs.open(file, "a+", 0755, function (err, fd) {
- if (err) {
- throw err;
- }
- log.debug('appending ' + data + ' to ' + file);
- Fs.write(fd, data, function (err, written) {
- if (err) {
- throw err;
- }
- });
- Fs.close(fd);
- });
+ Fs.appendFile(file, data, function (err) {
+ if (err) {
+ throw err;
+ }
+ log.debug('appending ' + data + ' to ' + file);
+ });
};

0 comments on commit 5d7a138

Please sign in to comment.