forked from mirror/MCSM-Daemon
修复 文件获取错误问题
This commit is contained in:
parent
5733f49bb6
commit
c7de9fa206
@ -79,21 +79,25 @@ export default class FileManager {
|
||||
const files: IFile[] = [];
|
||||
const dirs: IFile[] = [];
|
||||
fileNames.forEach((name) => {
|
||||
const info = fs.statSync(this.toAbsolutePath(name));
|
||||
if (info.isFile()) {
|
||||
files.push({
|
||||
name: name,
|
||||
type: 1,
|
||||
size: info.size,
|
||||
time: info.atime.toString()
|
||||
});
|
||||
} else {
|
||||
dirs.push({
|
||||
name: name,
|
||||
type: 0,
|
||||
size: info.size,
|
||||
time: info.atime.toString()
|
||||
});
|
||||
try {
|
||||
const info = fs.statSync(this.toAbsolutePath(name));
|
||||
if (info.isFile()) {
|
||||
files.push({
|
||||
name: name,
|
||||
type: 1,
|
||||
size: info.size,
|
||||
time: info.atime.toString()
|
||||
});
|
||||
} else {
|
||||
dirs.push({
|
||||
name: name,
|
||||
type: 0,
|
||||
size: info.size,
|
||||
time: info.atime.toString()
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
// 忽略一个文件信息获取错误,以防止导致整体错误
|
||||
}
|
||||
});
|
||||
files.sort((a, b) => (a.name > b.name ? 1 : -1));
|
||||
|
Loading…
Reference in New Issue
Block a user