tools_batch_files 1.0.29 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/settleFiles.js +18 -2
package/package.json
CHANGED
package/utils/settleFiles.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
const fs = require("fs");
|
2
2
|
const path = require("path");
|
3
|
-
const { logger } = require("../logger");
|
3
|
+
const { logger } = require("../utils/logger");
|
4
4
|
|
5
5
|
function findFileInDir(dir, fileName) {
|
6
6
|
const files = fs.readdirSync(dir);
|
@@ -25,6 +25,21 @@ function logFileSize(path) {
|
|
25
25
|
logger(`音频大小:${formattedSize}M`);
|
26
26
|
}
|
27
27
|
|
28
|
+
/**
|
29
|
+
* 确保目录存在,如果不存在则创建它
|
30
|
+
*/
|
31
|
+
function ensureDirSync(dirpath) {
|
32
|
+
try {
|
33
|
+
if (!fs.existsSync(dirpath)) {
|
34
|
+
fs.mkdirSync(dirpath, { recursive: true });
|
35
|
+
logger(`目录创建成功:${dirpath}`);
|
36
|
+
}
|
37
|
+
} catch (err) {
|
38
|
+
logger(`创建目录时出错:${err}`);
|
39
|
+
throw err;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
28
43
|
/**
|
29
44
|
* 上传失败后,存入新文件夹(手动创建)
|
30
45
|
*/
|
@@ -38,5 +53,6 @@ const moveFailFiles = (originFilePath, failPath) => {
|
|
38
53
|
module.exports = {
|
39
54
|
findFileInDir,
|
40
55
|
logFileSize,
|
41
|
-
|
56
|
+
ensureDirSync,
|
57
|
+
moveFailFiles,
|
42
58
|
};
|