首頁「沒被整理的檔案」修兩病:同一件事講兩次/不說是哪一個檔
leo 08-06 封測回報(附截圖+「他放一個 md 檔無法通過」)。
## ① 同一件事講兩次,而且「另外」前面沒有東西
截圖實況:
「看起來不是文件,所以跳過了。」 ← 底下是空的(非文件檔不逐檔點名)
「**另外**有 1 個不是文件的檔案(圖片、影片、壓縮檔之類)也沒有處理。」
真兇:app.go buildSkipped 的 else 分支先寫一句通用說明,
接著無條件再寫 Other 那句——後者的「另外」是為「兩種都有」寫的,
在「只有非文件檔」時就變成前面沒有東西可以「另外」。
解:該分支只講一句、自己帶數量,且不留 Other。「另外」只在兩種都有時出現。
## ② 只報總數=等於沒說(這才是 md 那題卡住的原因)
封測者放 .md 說「無法通過」,但畫面只寫「有 1 個不是文件的檔案」,
**沒說是哪一個** ⇒ 誰也判斷不出發生什麼事。
而 `.md` 明明在 allowedExt 白名單裡(scan.go:26),我在本機實測也一次就過:
"path":"arcrun-md-test.md","status":"ingested","http_status":200
⇒ 那個「1 個」必然不是他以為的那個檔(副檔名被 Windows 藏起來、存成別的格式…),
但沒有檔名就永遠查不出來。
解:scan 收集非文件檔的檔名(上限 5 個),一路帶到 status.json 與首頁。
「只報總數」在幾百張圖時是對的,在 1 個時是失職——少量就點名。
## 驗
· 兩支新測試釘住規則:只有非文件檔時不准出現第二句、不准出現「另外」;
兩種都有時「另外」才成立並帶數量
· 實際文案打出來看過(見下),不是只看測試綠
有 1 個檔案沒有被整理
看起來不是文件(圖片、影片、壓縮檔之類),所以跳過了。這是正常的,你不用做什麼。
· 我的筆記.md.txt
· 312 張圖的情況:列 5 個 +「…還有 307 個」,不洗版
· collector 全測試過、app 測試過、go vet 全綠
This commit is contained in:
@@ -48,6 +48,9 @@ var allowedExt = map[string]bool{
|
||||
//
|
||||
// 加新格式的順序:先列在這裡(使用者立刻看得到「還不支援」),
|
||||
// 等 convert.go 真的接上抽取器,再把它從這裡搬去 allowedExt。
|
||||
// maxOtherNames=非文件檔最多點名幾個。超過就只報總數(避免幾百張圖洗版)。
|
||||
const maxOtherNames = 5
|
||||
|
||||
var docLikeExt = map[string]bool{
|
||||
// 舊版 Office(OLE2 二進位,與 .docx/.xlsx/.pptx 是完全不同的格式)
|
||||
".doc": true, ".xls": true, ".ppt": true,
|
||||
@@ -63,7 +66,8 @@ var docLikeExt = map[string]bool{
|
||||
//
|
||||
// ⚠️ 刻意**不寫進 manifest**:它每輪由檔案系統重算,永遠反映現況。
|
||||
// (對照 t195 的坑:凡是存進 ManifestEntry 的跨輪欄位都得記得在 carry 段補一行,
|
||||
// 漏了就靜默歸零。這裡不建立那份債。)
|
||||
//
|
||||
// 漏了就靜默歸零。這裡不建立那份債。)
|
||||
type SkippedFile struct {
|
||||
Path string `json:"path"`
|
||||
Ext string `json:"ext"`
|
||||
@@ -102,7 +106,14 @@ type TriggerPayload struct {
|
||||
//(BuildSendablePayload 是 `sendable := *p` 淺拷貝,有 tag 就會一起送出去)。
|
||||
// ⇒ 留在記憶體裡,由 direct.go 收進 status.json,給 App 首頁用。
|
||||
Skipped []SkippedFile `json:"-"` // 像文件、但還讀不了的(逐檔點名)
|
||||
SkippedOther int `json:"-"` // 其餘非文件檔(圖片/影音/程式碼…)只計數
|
||||
SkippedOther int `json:"-"` // 其餘非文件檔(圖片/影音/程式碼…)總數
|
||||
// SkippedOtherNames=上面那些檔的檔名,**最多 maxOtherNames 個**。
|
||||
// 🔴 2026-08-06(leo 封測):封測者放了一個 .md 進去說「無法通過」,而畫面只寫
|
||||
// 「有 1 個不是文件的檔案」——**沒說是哪一個**,於是誰也判斷不出發生什麼事
|
||||
// (.md 明明在白名單裡,所以那個 1 一定是別的東西:可能副檔名被 Windows 藏起來、
|
||||
// 可能存成了別的格式)。只報總數在「幾百張圖」時是對的,在「1 個」時等於沒說。
|
||||
// ⇒ 少量時就點名,讓使用者自己一眼看出「喔,我存錯格式了」。
|
||||
SkippedOtherNames []string `json:"-"`
|
||||
}
|
||||
|
||||
type ScanOptions struct {
|
||||
@@ -154,6 +165,7 @@ func Scan(root string, m *Manifest, opts ScanOptions) (*TriggerPayload, error) {
|
||||
current := map[string]fileState{}
|
||||
var skipped []SkippedFile
|
||||
skippedOther := 0
|
||||
var skippedOtherNames []string
|
||||
err := filepath.WalkDir(root, func(p string, d fs.DirEntry, werr error) error {
|
||||
if werr != nil {
|
||||
return werr
|
||||
@@ -184,6 +196,12 @@ func Scan(root string, m *Manifest, opts ScanOptions) (*TriggerPayload, error) {
|
||||
}
|
||||
} else {
|
||||
skippedOther++
|
||||
// 只留前幾個:多了就變噪音(Obsidian 附件庫可能有幾百張 .png)。
|
||||
if len(skippedOtherNames) < maxOtherNames {
|
||||
if rel, rerr := filepath.Rel(root, p); rerr == nil {
|
||||
skippedOtherNames = append(skippedOtherNames, filepath.ToSlash(rel))
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -357,13 +375,14 @@ func Scan(root string, m *Manifest, opts ScanOptions) (*TriggerPayload, error) {
|
||||
}
|
||||
sort.Slice(skipped, func(i, j int) bool { return skipped[i].Path < skipped[j].Path })
|
||||
return &TriggerPayload{
|
||||
SchemaVersion: 1,
|
||||
FolderID: m.FolderID,
|
||||
Root: root,
|
||||
GeneratedAt: time.Now().Unix(),
|
||||
Events: events,
|
||||
Warnings: warnings,
|
||||
Skipped: skipped,
|
||||
SkippedOther: skippedOther,
|
||||
SchemaVersion: 1,
|
||||
FolderID: m.FolderID,
|
||||
Root: root,
|
||||
GeneratedAt: time.Now().Unix(),
|
||||
Events: events,
|
||||
Warnings: warnings,
|
||||
Skipped: skipped,
|
||||
SkippedOther: skippedOther,
|
||||
SkippedOtherNames: skippedOtherNames,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user