siyuan-note/siyuan · error

Conf.Language(377)

Error message

Conf.Language(377)

What it means

deferredSyncAssets reads the persisted deferred asset-download state and decrypts it with the repo key. If the data repo is not open (Conf.Repo is nil or has no key), it cannot decrypt the state and returns localized message 377: "Please switch to Download all before changing or resetting the data repository". Callers surface it wherever deferred assets must be reconciled.

Source

Thrown at kernel/model/asset_download.go:77

			identity = append(identity, filepath.Clean(c.Local.Endpoint))
		}
	}
	data, _ := json.Marshal(identity)
	return fmt.Sprintf("%x", sha256.Sum256(data))
}

// DeferredSyncAssets 仅读取逻辑清单,不发起下载。
func DeferredSyncAssets() ([]*entity.File, error) {
	return deferredSyncAssets()
}

func deferredSyncAssets() ([]*entity.File, error) {
	exists, err := assetDownloadStateExists()
	if err != nil || !exists {
		return nil, err
	}
	if Conf.Repo == nil || len(Conf.Repo.Key) == 0 {
		return nil, errors.New(Conf.Language(377))
	}
	return dejavu.ReadDeferredAssets(assetDownloadStatePath(), Conf.Repo.Key)
}

// validateAssetDownloadSourceScope 在公布新的账号身份前保留未完成的资源与历史恢复来源。
func validateAssetDownloadSourceScope(scope string) error {
	exists, err := assetDownloadStateExists()
	if err != nil || !exists {
		return err
	}
	if Conf.Repo == nil || len(Conf.Repo.Key) == 0 {
		return errors.New(Conf.Language(377))
	}
	stored, err := dejavu.ReadAssetDownloadScope(assetDownloadStatePath(), Conf.Repo.Key)
	if err != nil || stored == scope {
		return err
	}
	return requireCompleteAssetDownloads()

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Initialize/open the data repo (enter the repo key via the cloud sync dialog) so Conf.Repo.Key is set, then retry
  2. Switch the sync asset download mode to "Download all" and let pending downloads complete before changing or resetting the repo
  3. Remove the deferred asset-download state file in the workspace temp dir only if you accept losing the pending-download bookkeeping
  4. Log into the cloud account and reopen sync before resetting the data repository

Example fix

// before: repo closed while deferred state exists
curl -X POST http://127.0.0.1:6806/api/sync/performSync // fails with 377
// after: open the repo first
curl -X POST http://127.0.0.1:6806/api/repo/initRepoKeyFromCloud
curl -X POST http://127.0.0.1:6806/api/sync/performSync
Defensive patterns

Strategy: try-catch

Validate before calling

const sync = await fetchPost('/api/sync/getSyncInfo');
const repoReady = sync.data && sync.data.cloudName; // repo key initialized
if (!repoReady) throw new Error('Open the data repo before syncing deferred assets');

Try / catch

try { await ensureAssetLocal(...); } catch (e) { if (String(e).includes(Conf.Language ? Conf.Language(377) : 'Download all')) { await openRepoKey(); return ensureAssetLocal(...); } throw e; }

Prevention

When it happens

Trigger: Any caller (DeferredSyncAssets, EnsureAssetLocal, EnsureAssetPrefixLocal, ensureAllSyncAssets, requireCompleteAssetDownloads) running while a deferred-download state file exists but the data repo is closed — i.e. no cloud repo key because the user logged out, reset the data repo, or never initialized sync while a pending asset-download state remains.

Common situations: Resetting or switching the data repository while deferred asset downloads are pending; fresh workspace restore with asset-download state but no repo key; closing the cloud repo (closing the padlock) without completing pending downloads.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/f4315936f2db8e73. Report an issue: GitHub.