siyuan-note/siyuan · critical

dir [%s] has more than 1 file: %s

Error message

dir [%s] has more than 1 file:
%s

What it means

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.

Source

Thrown at kernel/util/runtime.go:359

			}

			checkFilenames := bytes.Buffer{}
			for _, entry := range entries {
				if !entry.IsDir() && strings.Contains(entry.Name(), "check_") {
					checkFilenames.WriteString(entry.Name())
					checkFilenames.WriteString("\n")
				}
			}
			lines := strings.Split(strings.TrimSpace(checkFilenames.String()), "\n")
			if 1 < len(lines) {
				buf := bytes.Buffer{}
				for _, line := range lines {
					buf.WriteString("  ")
					buf.WriteString(line)
					buf.WriteString("\n")
				}
				output := buf.String()
				ReportFileSysFatalError(fmt.Errorf("dir [%s] has more than 1 file:\n%s", dir, output))
				return
			}
		}

		if err = os.RemoveAll(tmp); err != nil {
			ReportFileSysFatalError(err)
			return
		}
	}
}

func IsCloudDrivePath(workspaceAbsPath string) bool {
	if isICloudPath(workspaceAbsPath) {
		return true
	}

	if isKnownCloudDrivePath(workspaceAbsPath) {
		return true

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Move the workspace out of ANY folder touched by a file-sync client, even ones not on SiYuan's known list.
  2. Pause or uninstall the sync client temporarily to confirm it is the cause, then keep the workspace excluded.
  3. Use SiYuan's official sync instead of a file-level sync client.
  4. Restart the kernel after relocating the workspace.

Example fix

// before: workspace synced via Syncthing (not in known list)
// kernel exits with: dir [...] has more than 1 file: check_consistency / check_consistency_renamed ...

// after: relocate workspace and exclude from Syncthing
// 设置 - 关于 - 工作空间 -> /Users/me/Documents/SiYuan (not in any sync share)
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check by running the same probe logic yourself before the kernel does
// (simplified): create a file, rename it, list the dir; if duplicates appear, abort.
func wouldDuplicate(path string) bool {
    tmp := filepath.Join(path, "probe")
    _ = os.WriteFile(tmp, []byte("x"), 0644)
    renamed := tmp + "_r"
    _ = os.Rename(tmp, renamed)
    _ = os.Rename(renamed, tmp)
    entries, _ := os.ReadDir(path)
    n := 0
    for _, e := range entries { if strings.HasPrefix(e.Name(), "probe") { n++ } }
    _ = os.Remove(tmp)
    return n > 1
}

Try / catch

// This error is FATAL (os.Exit). No catch is possible. Prevention only.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/c18844b941661305. Report an issue: GitHub.