修复脚本和日志列表获取软链接循环失败

This commit is contained in:
whyour 2024-04-21 21:59:02 +08:00
parent 6ca28190b0
commit 445dee00f7
3 changed files with 5 additions and 5 deletions

View File

@ -30,7 +30,7 @@ export async function getLastModifyFilePath(dir: string) {
arr.forEach(async (item) => {
const fullpath = path.join(dir, item);
const stats = await fs.stat(fullpath);
const stats = await fs.lstat(fullpath);
if (stats.isFile()) {
if (stats.mtimeMs >= 0) {
filePath = fullpath;
@ -257,7 +257,7 @@ export async function readDirs(
for (const file of files) {
const subPath = path.join(dir, file);
const stats = await fs.stat(subPath);
const stats = await fs.lstat(subPath);
const key = path.join(relativePath, file);
if (blacklist.includes(file) || stats.isSymbolicLink()) {
@ -300,7 +300,7 @@ export async function readDir(
.filter((x) => !blacklist.includes(x))
.map(async (file: string) => {
const subPath = path.join(dir, file);
const stats = await fs.stat(subPath);
const stats = await fs.lstat(subPath);
const key = path.join(relativePath, file);
return {
title: file,

View File

@ -515,7 +515,7 @@ export default class CronService {
files.map(async (x) => ({
filename: x,
directory: relativeDir.replace(config.logPath, ''),
time: (await fs.stat(`${dir}/${x}`)).mtime.getTime(),
time: (await fs.lstat(`${dir}/${x}`)).mtime.getTime(),
})),
)
).sort((a, b) => b.time - a.time);

View File

@ -371,7 +371,7 @@ export default class SubscriptionService {
files.map(async (x) => ({
filename: x,
directory: relativeDir.replace(config.logPath, ''),
time: (await fs.stat(`${dir}/${x}`)).mtime.getTime(),
time: (await fs.lstat(`${dir}/${x}`)).mtime.getTime(),
})),
)
).sort((a, b) => b.time - a.time);