Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annex: render missing content as pointers #28

Open
kousu opened this issue Nov 30, 2022 · 1 comment
Open

annex: render missing content as pointers #28

kousu opened this issue Nov 30, 2022 · 1 comment

Comments

@kousu
Copy link
Member

kousu commented Nov 30, 2022

In #22 I decided to show a 404 if annex content is missing:

test setup
p115628@joplin:~/src/neurogitea/test/test$ dd if=/dev/urandom of=blah2.nii.gz count=1 bs=1M
1+0 enregistrements lus
1+0 enregistrements écrits
1048576 octets (1,0 MB, 1,0 MiB) copiés, 0,0101098 s, 104 MB/s
p115628@joplin:~/src/neurogitea/test/test$ git add blah2.nii.gz 
p115628@joplin:~/src/neurogitea/test/test$ git commit -m "blah2"
[main 10bed66] blah2
 1 file changed, 1 insertion(+)
 create mode 100644 blah2.nii.gz
p115628@joplin:~/src/neurogitea/test/test$ git push  # notice we *don't* use `git annex sync --content` or `git annex copy --to origin`, so the content is missing
Locking support detected on remote "origin". Consider enabling it with:
  $ git config lfs.https://localhost/kousu/test.git/info/lfs.locksverify true
Énumération des objets: 4, fait.
Décompte des objets: 100% (4/4), fait.
Compression par delta en utilisant jusqu'à 128 fils d'exécution
Compression des objets: 100% (3/3), fait.
Écriture des objets: 100% (3/3), 374 octets | 374.00 Kio/s, fait.
Total 3 (delta 1), réutilisés 0 (delta 0), réutilisés du pack 0
remote: . Processing 1 references
remote: Processed 1 references in total
To localhost:kousu/test.git
   eaa831b..10bed66  main -> main

Screenshot 2022-11-29 at 20-49-41 test

Screenshot 2022-11-29 at 20-49-30 test

caused by this code:

https://github.com/neuropoly/gitea/blob/86630f4970824a7aa5f2e3ce5e060a3b41ddbcf1/routers/web/repo/view.go#L440-L452

But I just tested with Git LFS, by using the delete button in the LFS UI

test setup

Screenshot 2022-11-29 at 20-33-32 lfs-test

Screenshot 2022-11-29 at 20-37-58 lfs-test

causing the first of these files to be missing its content

Screenshot 2022-11-29 at 20-52-03 lfs-test

and in this case the missing file renders the LFS pointer as plaintext:

Screenshot 2022-11-29 at 20-52-14 lfs-test

This is subtle, I missed this in their code when I was putting in the annex version; they do

https://github.com/neuropoly/gitea/blob/86630f4970824a7aa5f2e3ce5e060a3b41ddbcf1/routers/web/repo/view.go#L400-L407

so:

  1. Read the LFS pointer
  2. Try to get the content
  3. If git_model.ErrLFSObjectNotExist (i.e. the content is missing) do nothing, including skipping the following block (because err != nil => meta == nil). This is an implicit fallback to the previous value of dataRc, which was the pointer file itself.

So my code in view.go needs to be tweaked to have the same sort of failover. And isAnnexFile should only be set if both the pointer and the content were successfully read.

@kousu
Copy link
Member Author

kousu commented Nov 30, 2022

For consistency, check for content in

https://github.com/neuropoly/gitea/blob/86630f4970824a7aa5f2e3ce5e060a3b41ddbcf1/modules/base/tool.go#L264-L268

too, because we want a symlink-based annex pointer with missing content to render the words "Symbolic Link"

Screenshot 2022-11-29 at 21-30-25 test

so it should render on the index pages with a matching icon like

Screenshot 2022-11-29 at 21-31-41 test

but it currently renders on the index like

Screenshot 2022-11-29 at 21-31-15 test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant