1

I've cloned Git repository with files stored in local ipfs, I've initialized ipfs special remote, however I cannot download files stored in there.

I've run: git annex copy --from ipfs as suggested in this page, but the files aren't downloaded. It's like git-annex doesn't see them there.


Here is my setup (this part works):

  1. I've local IPFS Deamon running (ipfs init; ipfs daemon).

  2. I've installed Git Annex (Apt/Brew install git-annex).

  3. Installed ipfs remote script (as per git-annex/special remotes/ipfs page):

    mkdir -v ~/bin
    wget -O ~/bin/git-annex-remote-ipfs https://git-annex.branchable.com/special_remotes/external/git-annex-remote-ipfs
    export PATH="$PATH:$HOME/bin"
    
  4. I've created a new repo (mkdir test01 && cd test01 && git init).

  5. I've committed a regular file (touch README.md; git add README.md; git commit -m'Initial commit' README.md).

  6. I've initialized git-annex (git annex init).

  7. I've initialized annex remote (git annex initremote ipfs type=external externaltype=ipfs encryption=none).

  8. I've committed ipfs file (echo test > ipfs-file.txt; git annex add ipfs-file.txt; git commit -m'Adds ipfs file' ipfs-file.txt).

  9. Copied to local ipfs object store (git annex copy --to ipfs).

  10. Synchronize local repository with remotes (git annex sync ipfs). I'm not sure if this is needed.

  11. I've confirmed file is at ipfs having ipfs address with CID assigned (git annex whereis ipfs-file.txt).

  12. git annex list outputs X__X ipfs-file.txt additionally confirming the file is at ipfs storage.

Cloning into new repo and downloading files from ipfs (this part doesn't work):

  1. Created another empty repo (mkdir ../test02 && cd ../test02 && git init).
  2. Pulled files from the previous repo (git pull ../test01).
  3. Now ipfs-file.txt is a symbolic link to non-existing file (ls -la ipfs-file.txt).
  4. I've initialized git-annex in the new repo (git annex init).
  5. I've initialized annex remote (git annex initremote ipfs type=external externaltype=ipfs encryption=none).
  6. Enabled ipfs remote (git annex enableremote ipfs). I don't think it's needed.
  7. I did sync (git annex sync ipfs). I'm not sure if this is needed.
  8. I've run: git annex copy --from ipfs, this doesn't do anything. I expect it to copy the files from ipfs remote.

I've run the following commands:

% git annex whereis ipfs-file.txt
whereis ipfs-file.txt (0 copies) failed
whereis: 1 failed

% git annex list                 
here
|web
||bittorrent
|||ipfs
||||
____ ipfs-file.txt

which suggest the file isn't present at ipfs remote (missing X), however it was in the 1st repository.

I've run git annex copy --from ipfs -d (with debug), but git-annex-remote-ipfs script isn't even called like it does on --to ipfs.

kenorb
  • 155,785
  • 88
  • 678
  • 743

1 Answers1

1

As a workaround, you could use git annex whereis to look up the ipfs address of the file in the original repository (test01) to obtain the IPFS CID for the file.

git annex whereis ipfs-file.txt

Then, in the new repository (test02), use the git annex registerurl command with the obtained IPFS CID.

git annex registerurl ipfs-file.txt /ipfs/Qm...

That should allow you to run git annex copy --from ipfs in the new repository (test02) and download the file.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the workaround, I had to do: `git annex registerurl SHA256E-s5--f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2.txt ipfs:QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH` (to accept the syntax), but still it it doesn't know `whereis` the file. I've added `set -ex` to the `git-annex-remote-ipfs` script, it gives me more output when running `git annex`, but it isn't much helpful. It's possible `git-annex-remote-ipfs` needs some fixing. – kenorb May 19 '23 at 23:50
  • OK, I hope it will be fixed. – VonC May 20 '23 at 04:31