kenorb
kenorb

Reputation: 166871

How to copy files from ipfs using git annex?

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.

Upvotes: 1

Views: 219

Answers (0)

Related Questions