{"record":{"id":"0714deec81fb2fff","repo":"siyuan-note/siyuan","slug":"read-destination-s-failed-w","errorCode":null,"errorMessage":"read destination [%s] failed: %w","messagePattern":"read destination \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/working_mobile.go","lineNumber":168,"sourceCode":"\tfrom string\n\tto   string\n}\n\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)","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/working_mobile.go#L150-L186","documentation":"migrateLegacyIOSWorkspace in kernel/util/working_mobile.go moves legacy iOS workspace entries into <workspaceBaseDir>/siyuan. It first lists the destination directory; if os.ReadDir fails, it returns \"read destination [<dir>] failed: <cause>\".","triggerScenarios":"The default workspace directory <workspaceBaseDir>/siyuan cannot be read — it does not exist and cannot be created/read, or an I/O error occurs during the directory listing.","commonSituations":"iOS container paths changed by the OS, sandbox permission changes after an app update, the default workspace directory being removed mid-migration.","solutions":["Verify the default workspace directory exists and is readable by the app","Ensure the parent workspaceBaseDir is accessible in the sandbox container","Recreate the default workspace directory if it was deleted","Re-run migration after app storage permissions are restored"],"exampleFix":"// before\nif readErr != nil {\n\treturn false, fmt.Errorf(\"read destination [%s] failed: %w\", defaultWorkspaceDir, readErr)\n}\n// after: tolerate a not-yet-created destination\nif readErr != nil {\n\tif !errors.Is(readErr, fs.ErrNotExist) {\n\t\treturn false, fmt.Errorf(\"read destination [%s] failed: %w\", defaultWorkspaceDir, readErr)\n\t}\n\t// destination missing means empty; proceed to create it\n}","handlingStrategy":"try-catch","validationCode":"// pre-check destination readability before migration\ndir := filepath.Join(workspaceBaseDir, \"siyuan\")\nif _, err := os.ReadDir(dir); err != nil && !os.IsNotExist(err) {\n\t// fix container access before migrating\n}","typeGuard":null,"tryCatchPattern":"migrated, err := migrateLegacyIOSWorkspace(...)\nif err != nil && strings.HasPrefix(err.Error(), \"read destination\") {\n\t// ensure sandbox file access; retry after permissions restored\n}","preventionTips":["Do not delete the default workspace directory mid-upgrade","Keep app sandbox storage permissions granted","Run migration before first launch of the new workspace layout"],"tags":["ios","migration","filesystem"],"backgroundTag":"directory-not-found","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"}