fix(asset): prevent removal of programmatically created assets#5702
fix(asset): prevent removal of programmatically created assets#5702DipakHalkude wants to merge 1 commit into
Conversation
How to testgit clone -b fix-asset-generator-removal https://github.com/DipakHalkude/hexo.git
cd hexo
npm install
npm test |
|
Thanks for working on this. I don’t think this PR is safe to merge in its current form. The main issue is that Because of that, this change breaks the existing cleanup behavior: assets whose source files no longer exist will now be kept instead of removed. The existing test There is also another problem: even when the programmatically inserted asset is preserved, the asset generator still returns a route whose Asset.save({
_id: 'Test',
path: 'Test',
modified: true
});
|
What does it do?
Fixes issue #5680 where programmatically created assets in processors were being removed by the asset generator.
The asset generator was checking for physical file existence and removing all assets without corresponding files, including those created programmatically with
modified: trueflag.Solution
Modified the asset generator to skip removal for assets marked with
modified: true. This allows plugins and processors to create virtual/assets programmatically that persist in the database.Changes Made
lib/plugins/generator/asset.ts: Added check forasset.modifiedflag before removing assetstest/scripts/generators/asset.test.js: Added comprehensive testsPull request tasks
Testing
Example Usage