siyuan-note/siyuan · warning
destination [ ] is not empty
Error message
destination [%s] is not empty
What it means
migrateLegacyIOSWorkspace refuses to move legacy entries when the destination <workspaceBaseDir>/siyuan already contains anything, returning "destination [<dir>] is not empty". This is a safety guard against clobbering an existing workspace.
Solutions
- Verify whether the content in <workspaceBaseDir>/siyuan is a real workspace in use; if so, migration is unnecessary and should be skipped
- Manually move needed legacy entries into the default workspace after resolving conflicts
- Clear or relocate the non-essential destination content, then re-run migration
- Ensure migration only runs before first launch of the new workspace layout
Example fix
// before
if 0 < len(destinationEntries) {
return false, fmt.Errorf("destination [%s] is not empty", defaultWorkspaceDir)
}
// after: skip migration gracefully instead of failing
if 0 < len(destinationEntries) {
return false, nil // destination already populated; nothing to migrate
} Defensive patterns
Strategy: fallback
Validate before calling
// check emptiness before attempting migration
dir := filepath.Join(workspaceBaseDir, "siyuan")
entries, _ := os.ReadDir(dir)
if len(entries) > 0 { /* destination in use: skip migration */ } Try / catch
migrated, err := migrateLegacyIOSWorkspace(...)
if err != nil && strings.Contains(err.Error(), "is not empty") {
// destination already in use: keep it and skip migration gracefully
} Prevention
- Run migration only before the default workspace is first used
- Do not pre-populate <base>/siyuan before migration
- Treat non-empty destination as 'already migrated' rather than an error condition
When it happens
Trigger: Migration runs when the default workspace directory already has content — e.g. the app already created/used the new default workspace, or a previous migration partially completed.
Common situations: Users who started the new version before migration ran; second device restore with pre-populated workspace; leftover files in the default workspace directory.
Related errors
- destination [ ] already exists
- move [ ] to [ ] failed
- stat destination [ ] failed
- read destination [ ] failed
- rollback [ ] to [ ] failed
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/559487e93d3ea6c2.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/util/working_mobile.go:171
func migrateLegacyIOSWorkspace(workspaceBaseDir string) (migrated bool, err error) {
if ContainerIOS != Container || !gulu.File.IsDir(workspaceBaseDir) {
return false, nil
}
for _, name := range []string{"conf", "data", "temp"} {
if !gulu.File.IsDir(filepath.Join(workspaceBaseDir, name)) {
return false, nil
}
}
defaultWorkspaceDir := filepath.Join(workspaceBaseDir, "siyuan")
destinationEntries, readErr := os.ReadDir(defaultWorkspaceDir)
if readErr != nil {
return false, fmt.Errorf("read destination [%s] failed: %w", defaultWorkspaceDir, readErr)
}
if 0 < len(destinationEntries) {
return false, fmt.Errorf("destination [%s] is not empty", defaultWorkspaceDir)
}
var moves []workspaceDirMove
for _, name := range legacyIOSWorkspaceEntries {
from := filepath.Join(workspaceBaseDir, name)
if _, statErr := os.Lstat(from); statErr != nil {
if errors.Is(statErr, fs.ErrNotExist) {
continue
}
return false, fmt.Errorf("stat source [%s] failed: %w", from, statErr)
}
to := filepath.Join(defaultWorkspaceDir, name)
if _, statErr := os.Lstat(to); statErr == nil {
return false, fmt.Errorf("destination [%s] already exists", to)
} else if !errors.Is(statErr, fs.ErrNotExist) {
return false, fmt.Errorf("stat destination [%s] failed: %w", to, statErr)
}View on GitHub (pinned to 9f775e8a12)