{"record":{"id":"559487e93d3ea6c2","repo":"siyuan-note/siyuan","slug":"destination-s-is-not-empty","errorCode":null,"errorMessage":"destination [%s] is not empty","messagePattern":"destination \\[(.+?)\\] is not empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/util/working_mobile.go","lineNumber":171,"sourceCode":"\nfunc migrateLegacyIOSWorkspace(workspaceBaseDir string) (migrated bool, err error) {\n\tif ContainerIOS != Container || !gulu.File.IsDir(workspaceBaseDir) {\n\t\treturn false, nil\n\t}\n\n\tfor _, name := range []string{\"conf\", \"data\", \"temp\"} {\n\t\tif !gulu.File.IsDir(filepath.Join(workspaceBaseDir, name)) {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\n\tdefaultWorkspaceDir := filepath.Join(workspaceBaseDir, \"siyuan\")\n\tdestinationEntries, readErr := os.ReadDir(defaultWorkspaceDir)\n\tif readErr != nil {\n\t\treturn false, fmt.Errorf(\"read destination [%s] failed: %w\", defaultWorkspaceDir, readErr)\n\t}\n\tif 0 < len(destinationEntries) {\n\t\treturn false, fmt.Errorf(\"destination [%s] is not empty\", defaultWorkspaceDir)\n\t}\n\n\tvar moves []workspaceDirMove\n\tfor _, name := range legacyIOSWorkspaceEntries {\n\t\tfrom := filepath.Join(workspaceBaseDir, name)\n\t\tif _, statErr := os.Lstat(from); statErr != nil {\n\t\t\tif errors.Is(statErr, fs.ErrNotExist) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn false, fmt.Errorf(\"stat source [%s] failed: %w\", from, statErr)\n\t\t}\n\n\t\tto := filepath.Join(defaultWorkspaceDir, name)\n\t\tif _, statErr := os.Lstat(to); statErr == nil {\n\t\t\treturn false, fmt.Errorf(\"destination [%s] already exists\", to)\n\t\t} else if !errors.Is(statErr, fs.ErrNotExist) {\n\t\t\treturn false, fmt.Errorf(\"stat destination [%s] failed: %w\", to, statErr)\n\t\t}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/working_mobile.go#L153-L189","documentation":"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.","triggerScenarios":"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.","commonSituations":"Users who started the new version before migration ran; second device restore with pre-populated workspace; leftover files in the default workspace directory.","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"],"exampleFix":"// before\nif 0 < len(destinationEntries) {\n\treturn false, fmt.Errorf(\"destination [%s] is not empty\", defaultWorkspaceDir)\n}\n// after: skip migration gracefully instead of failing\nif 0 < len(destinationEntries) {\n\treturn false, nil // destination already populated; nothing to migrate\n}","handlingStrategy":"fallback","validationCode":"// check emptiness before attempting migration\ndir := filepath.Join(workspaceBaseDir, \"siyuan\")\nentries, _ := os.ReadDir(dir)\nif len(entries) > 0 { /* destination in use: skip migration */ }","typeGuard":null,"tryCatchPattern":"migrated, err := migrateLegacyIOSWorkspace(...)\nif err != nil && strings.Contains(err.Error(), \"is not empty\") {\n\t// destination already in use: keep it and skip migration gracefully\n}","preventionTips":["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"],"tags":["ios","migration","conflict","workspace"],"backgroundTag":"directory-not-empty","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}