{"record":{"id":"c18844b941661305","repo":"siyuan-note/siyuan","slug":"dir-s-has-more-than-1-file-s","errorCode":null,"errorMessage":"dir [%s] has more than 1 file:\n%s","messagePattern":"dir \\[(.+?)\\] has more than 1 file:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"kernel/util/runtime.go","lineNumber":359,"sourceCode":"\t\t\t}\n\n\t\t\tcheckFilenames := bytes.Buffer{}\n\t\t\tfor _, entry := range entries {\n\t\t\t\tif !entry.IsDir() && strings.Contains(entry.Name(), \"check_\") {\n\t\t\t\t\tcheckFilenames.WriteString(entry.Name())\n\t\t\t\t\tcheckFilenames.WriteString(\"\\n\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tlines := strings.Split(strings.TrimSpace(checkFilenames.String()), \"\\n\")\n\t\t\tif 1 < len(lines) {\n\t\t\t\tbuf := bytes.Buffer{}\n\t\t\t\tfor _, line := range lines {\n\t\t\t\t\tbuf.WriteString(\"  \")\n\t\t\t\t\tbuf.WriteString(line)\n\t\t\t\t\tbuf.WriteString(\"\\n\")\n\t\t\t\t}\n\t\t\t\toutput := buf.String()\n\t\t\t\tReportFileSysFatalError(fmt.Errorf(\"dir [%s] has more than 1 file:\\n%s\", dir, output))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif err = os.RemoveAll(tmp); err != nil {\n\t\t\tReportFileSysFatalError(err)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc IsCloudDrivePath(workspaceAbsPath string) bool {\n\tif isICloudPath(workspaceAbsPath) {\n\t\treturn true\n\t}\n\n\tif isKnownCloudDrivePath(workspaceAbsPath) {\n\t\treturn true","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/util/runtime.go#L341-L377","documentation":"Reported via ReportFileSysFatalError (kernel/util/runtime.go:359) — TERMINATES THE KERNEL — when the filesystem consistency probe finds more than one 'check_*' file in the probe directory after a rename cycle. The probe writes one file, renames it back and forth 32 times, then lists the directory; if a cloud-sync client duplicated the file, >1 entry appears, proving the workspace is under a sync folder that will corrupt data. It is the empirical catch-all that fires when the path-based IsCloudDrivePath check (1154) missed a sync client.","triggerScenarios":"Workspace is under a sync-client folder SiYuan did not recognize by name/metadata (rare or regional sync client, or a generic folder being mirrored); the sync client replicated the probe's check_consistency file mid-rename so the directory listing contains both the original and the duplicated copy.","commonSituations":"A sync client not in the known list (Seafile, Syncthing, Mega, Resilio, a custom rsync mirror); OneDrive/Dropbox on a path the heuristic missed; aggressive sync client that creates temp duplicates during rename.","solutions":["Move the workspace out of ANY folder touched by a file-sync client, even ones not on SiYuan's known list.","Pause or uninstall the sync client temporarily to confirm it is the cause, then keep the workspace excluded.","Use SiYuan's official sync instead of a file-level sync client.","Restart the kernel after relocating the workspace."],"exampleFix":"// before: workspace synced via Syncthing (not in known list)\n// kernel exits with: dir [...] has more than 1 file: check_consistency / check_consistency_renamed ...\n\n// after: relocate workspace and exclude from Syncthing\n// 设置 - 关于 - 工作空间 -> /Users/me/Documents/SiYuan (not in any sync share)","handlingStrategy":"validation","validationCode":"// Pre-check by running the same probe logic yourself before the kernel does\n// (simplified): create a file, rename it, list the dir; if duplicates appear, abort.\nfunc wouldDuplicate(path string) bool {\n    tmp := filepath.Join(path, \"probe\")\n    _ = os.WriteFile(tmp, []byte(\"x\"), 0644)\n    renamed := tmp + \"_r\"\n    _ = os.Rename(tmp, renamed)\n    _ = os.Rename(renamed, tmp)\n    entries, _ := os.ReadDir(path)\n    n := 0\n    for _, e := range entries { if strings.HasPrefix(e.Name(), \"probe\") { n++ } }\n    _ = os.Remove(tmp)\n    return n > 1\n}","typeGuard":null,"tryCatchPattern":"// This error is FATAL (os.Exit). No catch is possible. Prevention only.","preventionTips":["Keep the workspace out of ANY folder mirrored by a sync client — including ones SiYuan does not name (Syncthing, Seafile, Mega, Resilio).","If unsure, pause the sync client, restart SiYuan, and see if the error clears; that confirms the cause.","Use SiYuan's official sync; do not stack file-level sync on top.","Re-run the kernel after relocating the workspace to a clean local directory."],"tags":["filesystem","cloud-sync","fatal","workspace","consistency","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}