lyg
2024-06-14 8d546341fbf8fc45543cf33e40097bae994cdfd5
清理文本栈溢出异常处理
2个文件已修改
17 ■■■■ 已修改文件
config.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.mjs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config.json
@@ -3,10 +3,10 @@
  "startRow": 1,
  
  "//结束行号,从0开始,不包含该行": "//",
  "endRow": 2001,
  "endRow": 200,
  "//线程数": "//",
  "threadSize": 4,
  "threadSize": 10,
  "//定时结束时间,单位分钟,0表示不设置定时结束时间": "//",
  "endOfTime": 0,
src/main.mjs
@@ -351,7 +351,17 @@
              text = /(.|\n)*<pre>((.|\n)*)<\/pre>(.|\n)*/g.exec(text)[2];
              fs.writeFileSync(filepath, text, 'utf-8');
            }
            try {
            fs.writeFileSync(filepath + '.result.txt', cleanText(text), 'utf-8');
            } catch (e) {
              reject(e);
              try {
                out.close();
                fs.unlink(filepath, (e) => console.error(e));
              } catch (e) {
                console.error(e);
              }
            }
          }, 1000);
          resolve(true);
        });
@@ -588,3 +598,6 @@
  main();
}
// const filepath = "D:\\projects\\book-crawler\\downloads\\10231261 978-1-331-76167-9.txt";
// const text = fs.readFileSync(filepath, 'utf8');
// fs.writeFileSync(filepath + '.result.txt', cleanText(text), 'utf-8');