Open ghost opened 9 years ago
I Build a wrapper around your module to prevent this behaviour:
var diskinfo = require("diskinfo");
filesystem = { distinct: function (array) { var result = []; array.forEach(function (entry) { var same = result.filter(function (value) { return value.mounted === entry.mounted; });
if(same.length <= 0)
result.push(entry);
});
return result;
},
search: function (onSuccess, onError) {
diskinfo.getDrives(function(error, disks){
if (error)
return onError(error);
var result = filesystem.distinct(disks);
return onSuccess(result);
});
}
};
module.exports = filesystem;
if you leave this running for a long time with that wrapper you will have a nice memory leak
I've suggested a change by commit to fix this
it's a bug. function getDrives should reset aDrives; at getDrives entry insert one line: aDrives = [];
getDrives函数存在bug,应该在函数入口处重置aDrives变量为空数组:aDrives = [];
When i call getDrives multiple times (on Windows) i get duplicated entries inside that array. The cause seems to be multiple calls of getDrives, before one call ends.
Best regards
Michael