用sonnet4.6重写把后端改成nodejs#409
Conversation
|
开始时间是0220的23:30,测试一下。一万多行 重写要多久。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04435cc1bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| app.get("", listHistory); | ||
| app.post("", upsertProgress); |
There was a problem hiding this comment.
Expose history handlers on /list and /record
Both handlers are mounted at the history prefix root, so the backend only serves GET/POST /api/v1/history, but the current frontend and generated client call GET /api/v1/history/list and POST /api/v1/history/record (see frontend/src/routes/_layout/history.tsx and frontend/src/routes/_layout/read.tsx). This mismatch makes history fetch/save fail as soon as the Node backend is used.
Useful? React with 👍 / 👎.
| fs_roots: config.FS_ROOTS | ||
| ? config.FS_ROOTS.split(",").map(r => r.trim()).filter(Boolean) | ||
| : [], |
There was a problem hiding this comment.
Return
fs_roots in settings as a string
The settings response now serializes fs_roots as an array, but the existing UI expects a comma-separated string and immediately calls .split(",") (frontend/src/routes/_layout/settings.tsx), so a non-empty response will throw value.split is not a function and break settings rendering. Keeping wire format compatible avoids a client runtime error.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| export async function settingsRoutes(app: FastifyInstance) { | ||
| app.get("", getSettings); |
There was a problem hiding this comment.
Register a PUT handler for /api/v1/settings
Only GET is registered for this route, but the settings page persists changes with PUT /api/v1/settings (frontend/src/routes/_layout/settings.tsx), so saving FS roots/favorite/already-read paths cannot work against this backend. This is a functional API regression for user settings updates.
Useful? React with 👍 / 👎.
| app.setNotFoundHandler((_req, reply) => { | ||
| const indexPath = path.join(frontendDist, "index.html"); | ||
| if (fs.existsSync(indexPath)) { | ||
| return reply.type("text/html").send(fs.createReadStream(indexPath)); |
There was a problem hiding this comment.
Bypass SPA index fallback for unmatched API routes
When frontend/dist exists, the global not-found handler serves index.html for every unknown path, including /api/..., so missing API endpoints return HTML with status 200 instead of a JSON 404. That causes API consumers to fail with parse/runtime errors and hides which endpoint is actually unsupported.
Useful? React with 👍 / 👎.
| export function getExt(filepath: string): string { | ||
| return path.extname(filepath).toLowerCase(); |
There was a problem hiding this comment.
Detect
.tar.gz archives before calling extname
getExt relies on path.extname, which only returns the final suffix (e.g. .gz for file.tar.gz), so ARCHIVE_SUFFIXES entry .tar.gz is never matched in getFileType. As a result .tar.gz files are misclassified as unknown, and archive-specific behavior is skipped for them.
Useful? React with 👍 / 👎.
|
连续长时间写,ai会注意力丢失。 |
**IO与后端性能:** `Promise.all()` 并行化目录 stat 操作;schema.sql 添加 13 个索引覆盖所有 WHERE/JOIN 字段;所有列表接口强制分页(带 max cap);文件服务全部使用 `createReadStream` 流式处理。 **代码质量与UT:** 新增 history、parse、recService、repository-boundary 四个测试文件,修复 fs.test.ts 的 5 个失败(改用 `fs.promises` 异步 mock),全部 12 个测试文件 230 个用例通过。 **对接与类型安全:** 前端广泛使用 `?.` 可选链;消除了 `settings.tsx` 和 `useFileNavigation.ts` 中的 `as any`,后端源码零 `any`;全局错误通过 `QueryCache/MutationCache` 的 `onError` + `showErrorToast` 实现透传。 额外:应用户要求,用 `p-limit` 为 thumbnail 生成(并发 3)和 archive 解压(并发 2)加入了 HDD 保护。
- `files` 表保留历史记录,通过 `is_missing` 标志位 + `last_seen_at` 时间戳区分"存在"和"已消失" - `scanDirectory` 扫描每个目录后调用 `markMissingInFolder`,将磁盘上消失的文件标记为 `is_missing=1`,保留记录不删除 - 搜索端通过 `presence_filter` 控制结果范围:默认只返回存在的文件(`is_missing=0`),`all` 含历史记录,`watched` 只返回有观看进度的,`scanned_recent` 只返回 10 分钟内扫描到的 - 清理了所有废弃字段引用(`fingerprint`/`scan_state`)和已废弃的 `syncFileTable` 接口(前后端均已移除)
…-zip-files fix: expose avg_image_size in /archive/extract response schema
Openapi fix
python不知道为什么会害windows狂删AppData。害我重装系统两次。
正好测试一下sonnet 4.6的实力。