Revert "fix: 兼容微信新目录结构多一层嵌套导致账号目录识别失败的问题"

This reverts commit 5f6b0e8960.
This commit is contained in:
hicccc77
2026-03-28 17:30:56 +08:00
parent 5f6b0e8960
commit 22d8049c2c

View File

@@ -218,34 +218,22 @@ export class DbPathService {
scanWxidCandidates(rootPath: string): WxidInfo[] {
const wxids: WxidInfo[] = []
const scanOneLevelForCandidates = (scanPath: string) => {
if (!existsSync(scanPath)) return
const entries = readdirSync(scanPath)
for (const entry of entries) {
const entryPath = join(scanPath, entry)
let stat: ReturnType<typeof statSync>
try { stat = statSync(entryPath) } catch { continue }
if (!stat.isDirectory()) continue
const lower = entry.toLowerCase()
if (lower === 'all_users') continue
if (!entry.includes('_')) continue
wxids.push({ wxid: entry, modifiedTime: stat.mtimeMs })
}
}
try {
scanOneLevelForCandidates(rootPath)
// 兜底:往下再找一层(兼容 2.0b4.0.9/xwechat_files/wxid_xxx 结构)
if (wxids.length === 0 && existsSync(rootPath)) {
const subDirs = readdirSync(rootPath)
for (const sub of subDirs) {
const subPath = join(rootPath, sub)
try { if (!statSync(subPath).isDirectory()) continue } catch { continue }
scanOneLevelForCandidates(subPath)
if (existsSync(rootPath)) {
const entries = readdirSync(rootPath)
for (const entry of entries) {
const entryPath = join(rootPath, entry)
let stat: ReturnType<typeof statSync>
try { stat = statSync(entryPath) } catch { continue }
if (!stat.isDirectory()) continue
const lower = entry.toLowerCase()
if (lower === 'all_users') continue
if (!entry.includes('_')) continue
wxids.push({ wxid: entry, modifiedTime: stat.mtimeMs })
}
}
if (wxids.length === 0) {
const rootName = basename(rootPath)
if (rootName.includes('_') && rootName.toLowerCase() !== 'all_users') {
@@ -294,25 +282,6 @@ export class DbPathService {
const modifiedTime = this.getAccountModifiedTime(fullPath)
wxids.push({ wxid: account, modifiedTime })
}
// 兜底:如果一层找不到,尝试往下再找一层子目录(兼容 2.0b4.0.9/xwechat_files/wxid_xxx 结构)
if (wxids.length === 0) {
try {
const subDirs = readdirSync(rootPath)
for (const sub of subDirs) {
const subPath = join(rootPath, sub)
try {
if (!statSync(subPath).isDirectory()) continue
} catch { continue }
const subAccounts = this.findAccountDirs(subPath)
for (const account of subAccounts) {
const fullPath = join(subPath, account)
const modifiedTime = this.getAccountModifiedTime(fullPath)
wxids.push({ wxid: account, modifiedTime })
}
}
} catch { }
}
} catch { }
const sorted = wxids.sort((a, b) => {