siyuan-note/siyuan · error

Conf.Language(371)

Error message

Conf.Language(371)

What it means

Before copying the historical notebook snapshot back into the workspace, RollbackNotebookHistory checks whether data/<boxID> already exists. If a notebook with that ID is present, the rollback is refused with the localized message Conf.Language(371) to avoid clobbering or merging into an existing notebook.

Solutions

  1. Remove or rename the existing notebook with that ID first if the historical copy should replace it
  2. Roll back individual documents instead of the whole notebook if the notebook still exists
  3. Choose a different history entry (before the notebook was recreated) or create a fresh notebook and copy content

Example fix

// before
rollbackNotebookHistory(p) // data/<boxID> still exists -> error 371
// after
if (!filelock.IsExist(filepath.Join(util.DataDir, boxID))) { rollbackNotebookHistory(p) }
Defensive patterns

Strategy: validation

Validate before calling

const boxID = parseBoxIDFromHistoryPath(p);
if (fs.existsSync(path.join(dataDir, boxID))) { throw new Error('notebook already exists; choose doc-level rollback or remove it first'); }

Try / catch

try { await rollbackNotebookHistory(p); } catch (e) { if (isNotebookExistsMessage(e)) { promptUserConflictResolution(boxID); } else { throw e; } }

Prevention

When it happens

Trigger: Calling RollbackNotebookHistory for a deleted-notebook history entry while a notebook with the same boxID exists under data/ — e.g. the notebook was recreated or restored already, or only some documents were deleted so the notebook itself remains.

Common situations: Users deleting and recreating a notebook, then trying to roll back the deletion record; retrying a rollback that partially succeeded; restoring history after sync re-created the notebook.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/history.go:660

func RollbackNotebookHistory(historyPath string) (err error) {
	historyPath, err = validateHistoryPath(historyPath)
	if err != nil {
		return
	}
	boxID, err := validateNotebookHistoryPath(historyPath)
	if err != nil {
		return
	}
	if _, loaded := boxLock.LoadOrStore(boxID, true); loaded {
		return errors.New(Conf.Language(239))
	}
	defer boxLock.Delete(boxID)

	from := historyPath
	to := filepath.Join(util.DataDir, boxID)
	if filelock.IsExist(to) {
		return errors.New(Conf.Language(371))
	}

	if err = filelock.CopyNewtimes(from, to); err != nil {
		logging.LogErrorf("copy file [%s] to [%s] failed: %s", from, to, err)
		return
	}

	IncSync()
	ReloadFiletree()
	util.PushMsg(Conf.Language(372), 3000)
	return nil
}

func validateNotebookHistoryPath(historyPath string) (boxID string, err error) {
	rel, err := filepath.Rel(util.HistoryDir, historyPath)
	if err != nil {
		return "", fmt.Errorf("invalid notebook history path [%s]", historyPath)
	}

View on GitHub (pinned to 9f775e8a12)