You are reading a single comment by @lenxu and its replies. Click here to read the full conversation.
  • 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());
        });
      });
    }
    
About

Avatar for lenxu @lenxu started