{"record":{"id":"0137a38a822d1b02","repo":"siyuan-note/siyuan","slug":"asset-path-contains-an-unresolved-symbolic-link","errorCode":null,"errorMessage":"asset path contains an unresolved symbolic link [%s]","messagePattern":"asset path contains an unresolved symbolic link \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/asset_download_read.go","lineNumber":46,"sourceCode":")\n\n// ResolveAssetPathWithMissingLeaf 校验尚未下载的路径，已存在的父目录仍须通过符号链接校验。\nfunc ResolveAssetPathWithMissingLeaf(absPath string) (string, error) {\n\tcurrent := filepath.Clean(absPath)\n\tvar missing []string\n\tfor {\n\t\tresolved, err := ResolveRealPath(current)\n\t\tif err == nil {\n\t\t\tfor i := len(missing) - 1; i >= 0; i-- {\n\t\t\t\tresolved = filepath.Join(resolved, missing[i])\n\t\t\t}\n\t\t\treturn resolved, nil\n\t\t}\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif info, statErr := os.Lstat(current); statErr == nil && info.Mode()&os.ModeSymlink != 0 {\n\t\t\treturn \"\", fmt.Errorf(\"asset path contains an unresolved symbolic link [%s]\", current)\n\t\t}\n\t\tparent := filepath.Dir(current)\n\t\tif parent == current {\n\t\t\treturn \"\", err\n\t\t}\n\t\tmissing = append(missing, filepath.Base(current))\n\t\tcurrent = parent\n\t}\n}\n\n// deferredAssetPath 只解析同步清单，不访问网络，也不以未下载状态推断文件已删除。\nfunc deferredAssetPath(relativePath, boxID string, includeEncrypted bool) (string, error) {\n\tfiles, err := DeferredSyncAssets()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn deferredAssetPathFromFiles(relativePath, boxID, includeEncrypted, files)\n}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/asset_download_read.go#L28-L64","documentation":"ResolveAssetPathWithMissingLeaf walks an asset path component by component; when a stat fails with not-exist but Lstat shows the component itself is a symlink, the symlink target cannot be resolved (e.g. dangling or loop), so it fails fast with 'asset path contains an unresolved symbolic link [%s]' naming the offending component. This prevents silently treating a broken symlink as a merely missing file to download.","triggerScenarios":"Calling ResolveAssetPathWithMissingLeaf (directly or through ResolveDataAssetPath, deferredAssetPathFromFiles, unusedAssetsContainPath) on a workspace data dir where an assets path segment is a symlink whose target does not exist or is unreachable.","commonSituations":"Workspace synced/restored across machines where absolute or machine-specific symlinks dangle; user replaced an assets folder with a symlink to an unmounted drive; cloud-drive placeholder symlinks (OneDrive/Dropbox on-demand files) that cannot resolve.","solutions":["Inspect the path component named in the error and repair or remove the dangling symlink (ln -sfn to a valid target)","Remount the drive or re-login to the cloud drive so symlink targets resolve","Replace symlinks in assets/ with real files if the workspace is synced across devices (SiYuan does not support symlinked asset segments)","Re-copy the assets directory without symlinks from a backup"],"exampleFix":"// shell repair\n# before: dangling symlink\nassets/img -> /mnt/usb/photos   # /mnt/usb not mounted\n# after\nln -sfn /data/photos assets/img  # or copy the real files into assets/img","handlingStrategy":"validation","validationCode":"info, err := os.Lstat(assetPath)\nif err == nil && info.Mode()&os.ModeSymlink != 0 {\n    target, lerr := os.Readlink(assetPath)\n    if lerr != nil { /* skip or repair */ }\n    if _, serr := os.Stat(target); serr != nil { return fmt.Errorf(\"dangling symlink %s -> %s\", assetPath, target) }\n}","typeGuard":null,"tryCatchPattern":"resolved, err := model.ResolveDataAssetPath(lookupPath)\nif err != nil && strings.Contains(err.Error(), \"unresolved symbolic link\") {\n    repairOrSkipSymlink(extractPath(err))\n}","preventionTips":["Do not use symlinks inside notebook assets folders, especially in synced workspaces","Avoid cloud-drive placeholder folders (OneDrive/Dropbox on-demand) as symlinked asset targets","Audit workspaces after machine migrations with a dangling-symlink scan (find -xtype l)","Copy real files instead of linking when importing assets from external locations"],"tags":["filesystem","symlink","asset-resolution","path-resolution"],"backgroundTag":"file-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"}