Skip to content

annex: render missing content as pointers #28

Open
@kousu

Description

@kousu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions