Additionally, I've encountered an issue when using the fs module. Specifically, when I call the fs.appendFileSync(filename, data); method and I repeatedly execute this code block within a setInterval function, I'm experiencing issues with missing or inconsistent file writes. Could you please assist me in resolving this when you have the time?
function downloadData(filename) {
require('http').get("http://xxx.com/pic/"+filename, function(res) {
var i = 0;
res.on('data', function(data) {
i+=1;
console.log('download:' + filename + " chunk =>" + i + '...');
fs.appendFileSync(filename, data);
});
res.on('close', function(data) {
console.log("Connection closed");
console.log(fs.readdirSync());
});
});
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Additionally, I've encountered an issue when using the fs module. Specifically, when I call the fs.appendFileSync(filename, data); method and I repeatedly execute this code block within a setInterval function, I'm experiencing issues with missing or inconsistent file writes. Could you please assist me in resolving this when you have the time?