[bug]pkg打包后,运行环境里的文件夹检查结果不准确。 #4166
pkjy
started this conversation in
General / 闲聊
Replies: 2 comments 2 replies
-
最好是能判断出是 pkg 环境,只在 static-file 中做一些处理,收敛影响范围。 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
midway/packages/static-file/src/middleware/static.middleware.ts
Line 62 in 696137f
这行代码检查了静态资源文件夹是否存在,使用了
midway/packages/core/src/util/fs.ts
Line 5 in 696137f
fs.access
来判断。pkg打包后会生成
/snapshot
的一个虚拟目录。实测发现该方法检查不到pkg运行时的虚拟文件夹。
我把上面的62行的判断注释后,能正常访问到静态资源。否则会一直报错
DirectoryNotFoundError: Path /snapshot/project/public not exist, please check it.
建议改为fs.readdirSync来判断,我这个case里试了下是可行的。
以下是从gpt那获得的一些建议。
Beta Was this translation helpful? Give feedback.
All reactions