fix: symlink 探测有界并发 + UNC 标记平台中性化(回应 CR/自审)
- fs-tree: symlink 目标 stat 从串行改为 32 并发工作池(readdir 流关闭后统一 探测),symlink 密集/网络目标目录不再累加延迟;顺序与分类语义不变 - html-route: 解码不再重建反斜杠 UNC,统一重建为平台中性的 //server/share/... 前斜杠形态(win32/POSIX 均正确 resolve),从而删除 windowsPathStyle 平台信号 与 client isWindowsStylePath 助手;同时解决无 cwd 时正斜杠 UNC 的往返盲点 - 测试/文档同步;移除未使用的 isPosix
This commit is contained in:
1 parent
9652bbda59
commit
be95787c00
10 files changed
+104
-114
No files matched your search
+5
-25
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isAbsolutePath, isWindowsStylePath, relativeTo } from '../src/client/paths.ts'
|
||||
import { isAbsolutePath, relativeTo } from '../src/client/paths.ts'
|
||||
import { resolveSidebarPath } from '../src/client/produced-files.ts'
|
||||
import { htmlUrl } from '../src/client/api.ts'
|
||||
|
||||
@@ -56,33 +56,13 @@ describe('path helpers', () => {
|
||||
expect(isAbsolutePath('rel/x.ts')).toBe(false)
|
||||
})
|
||||
|
||||
it('detects windows-style session paths (platform signal for the html route)', () => {
|
||||
expect(isWindowsStylePath('C:\\work\\proj')).toBe(true)
|
||||
expect(isWindowsStylePath('C:/work/proj')).toBe(true)
|
||||
expect(isWindowsStylePath('\\\\server\\share\\proj')).toBe(true)
|
||||
expect(isWindowsStylePath('//server/share/proj')).toBe(false) // ambiguous form needs the drive/backslash signal
|
||||
expect(isWindowsStylePath('/Users/me/code')).toBe(false)
|
||||
})
|
||||
|
||||
it('htmlUrl marks UNC paths from the file path itself (cwd-independent signal)', () => {
|
||||
// cwd not hydrated yet: the unambiguous backslash UNC path must still
|
||||
// keep its '//' marker, or win32 would decode /server/... against the
|
||||
// current drive and the isWithin fence would reject the preview (403).
|
||||
it('htmlUrl always marks UNC paths (platform-neutral marker)', () => {
|
||||
// The marker is platform-neutral now: the host resolves the decoded
|
||||
// '//server/share/...' form per-platform, so no cwd/OS signal is needed.
|
||||
expect(htmlUrl({ sessionId: 's' }, '\\\\server\\share\\proj\\a.html'))
|
||||
.toBe('/sidebar/html/s//server/share/proj/a.html')
|
||||
// A forward-slash-form cwd (still Windows) does not mask the backslash path.
|
||||
expect(htmlUrl({ sessionId: 's', cwd: '//server/share/proj' }, '\\\\server\\share\\proj\\a.html'))
|
||||
.toBe('/sidebar/html/s//server/share/proj/a.html')
|
||||
// Both cwd and path in the forward-slash UNC form: the '//' path matches
|
||||
// the '//' cwd, so it is UNC and keeps the marker (win32 round-trips).
|
||||
expect(htmlUrl({ sessionId: 's', cwd: '//server/share/proj' }, '//server/share/proj/a.html'))
|
||||
.toBe('/sidebar/html/s//server/share/proj/a.html')
|
||||
// A Windows drive cwd marks forward-slash UNC paths.
|
||||
expect(htmlUrl({ sessionId: 's', cwd: 'C:\\work' }, '//server/share/proj/a.html'))
|
||||
.toBe('/sidebar/html/s//server/share/proj/a.html')
|
||||
// A POSIX session keeps forward-slash paths marker-free.
|
||||
expect(htmlUrl({ sessionId: 's', cwd: '/home/me' }, '//server/share/a.html'))
|
||||
.toBe('/sidebar/html/s/server/share/a.html')
|
||||
.toBe('/sidebar/html/s//server/share/a.html')
|
||||
expect(htmlUrl({ sessionId: 's', cwd: '/home/me' }, '/home/me/index.html'))
|
||||
.toBe('/sidebar/html/s/home/me/index.html')
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user