fix(lfs): fixes lfs pointers in editorial workflow #4613
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Without this commit, the CMS would alter the pointer files for each large media file whenever you edit a draft in editorial mode. The problem is that the filesize, blob and name are not available at the time when a commit is being generated which leads to all pointer files looking like this when you edit a draft that already contained an LFS object (i.e. first time adding an image works but editing text afterward will lead to this issue):
This PR fixes this problem by skipping all media files that do not have a name. Alternatively, there could be check for size == 0 instead.
I also thought about loading the correct metadata and blobs in the
unpublishedEntryMediaFile
inbackend-git-gateway
but that causes additional loading time every time someone opens a draft, so I believe skipping the commits when saving a draft is the better option. Happy to make adjustments to this though if needed. I'm really looking forward for this to be fixed because this bug makes using editorial workflow with images in LFS a huge pain.Steps to reproduce the issue:
Test plan
Ran
yarn test
and tested the behavior with a netlify-hosted blog page using git-gateway backed by github and netlify-lfs.Thanks for looking into this. Netlify CMS is awesome!
A picture of a cute animal (not mandatory but encouraged)