siyuan-note/siyuan · error

Conf.Sync.Stat

Error message

Conf.Sync.Stat

What it means

After the mandatory sync in SyncDataBeforeEnableEncryptedNotebook, if syncDataLocked returns an error the function surfaces Conf.Sync.Stat — the last sync status text — when non-empty, instead of the raw error. Seeing this message means a sync executed on behalf of the enable-encrypted-notebook flow failed, and the user-facing cause is stored in the sync status string.

Solutions

  1. Read Conf.Sync.Stat / the sync dialog status to learn the underlying sync failure cause
  2. Fix the root cause (network, cloud auth, provider errors) and retry enabling the encrypted notebook
  3. Inspect kernel logs around the failed syncDataLocked call for the detailed error
Defensive patterns

Strategy: try-catch

Validate before calling

// no pre-call check; failure surfaces via Conf.Sync.Stat after the sync attempt

Try / catch

if err := model.SyncDataBeforeEnableEncryptedNotebook(); err != nil {
    log.Println("pre-enable sync failed:", conf.Conf.Sync.Stat, err)
    // show Conf.Sync.Stat to the user and abort key-system creation
}

Prevention

When it happens

Trigger: syncDataLocked(false,true) fails during EnableEncryptedNotebookWithSync while Conf.Sync.Stat holds a non-empty status message from the failed sync.

Common situations: Network failure or cloud provider error during the forced pre-enable sync; authentication token expired; remote snapshot conflict — the actual reason is in Conf.Sync.Stat/kernel logs.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/8eadcb0f47facc88. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/sync.go:248

// SyncDataBeforeEnableEncryptedNotebook 在启用加密笔记本前执行一次完整同步。
// 未启用数据同步时直接返回;已启用数据同步时,任何同步失败都会阻止继续创建新的密钥体系。
func SyncDataBeforeEnableEncryptedNotebook() error {
	if !Conf.Sync.Enabled {
		return nil
	}
	if conf.ProviderS3 != Conf.Sync.Provider && !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
		return errors.New(Conf.Language(123))
	}
	if !checkSync(false, false, true) {
		return errors.New(Conf.Language(53))
	}

	// 不复用请求合并状态,确保调用返回前确实完成了一次由当前启用操作发起的完整同步。
	lockSync()
	defer unlockSync()
	if err := syncDataLocked(false, true); err != nil {
		if Conf.Sync.Stat != "" {
			return errors.New(Conf.Sync.Stat)
		}
		return err
	}
	return nil
}

func lockSync() {
	syncLock.Lock()
	isSyncing.Store(true)
}

func unlockSync() {
	isSyncing.Store(false)
	syncLock.Unlock()
}

type syncRequestState struct {
	requested atomic.Uint64

View on GitHub (pinned to 9f775e8a12)