Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit c7de9fa

Browse files
committed
修复 文件获取错误问题
1 parent 5733f49 commit c7de9fa

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/service/system_file.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,25 @@ export default class FileManager {
7979
const files: IFile[] = [];
8080
const dirs: IFile[] = [];
8181
fileNames.forEach((name) => {
82-
const info = fs.statSync(this.toAbsolutePath(name));
83-
if (info.isFile()) {
84-
files.push({
85-
name: name,
86-
type: 1,
87-
size: info.size,
88-
time: info.atime.toString()
89-
});
90-
} else {
91-
dirs.push({
92-
name: name,
93-
type: 0,
94-
size: info.size,
95-
time: info.atime.toString()
96-
});
82+
try {
83+
const info = fs.statSync(this.toAbsolutePath(name));
84+
if (info.isFile()) {
85+
files.push({
86+
name: name,
87+
type: 1,
88+
size: info.size,
89+
time: info.atime.toString()
90+
});
91+
} else {
92+
dirs.push({
93+
name: name,
94+
type: 0,
95+
size: info.size,
96+
time: info.atime.toString()
97+
});
98+
}
99+
} catch (error) {
100+
// 忽略一个文件信息获取错误,以防止导致整体错误
97101
}
98102
});
99103
files.sort((a, b) => (a.name > b.name ? 1 : -1));

0 commit comments

Comments
 (0)