The web can be used as a special remote too.

# git annex addurl http://example.com/video.mpeg
addurl example.com_video.mpeg (downloading http://example.com/video.mpeg)
########################################################## 100.0%
ok

Now the file is downloaded, and has been added to the annex like any other file. So it can be renamed, copied to other repositories, and so on.

Note that git-annex assumes that, if the web site does not 404, and has the right file size, the file is still present on the web, and this counts as one copy of the file. So it will let you remove your last copy, trusting it can be downloaded again:

# git annex drop example.com_video.mpeg
drop example.com_video.mpeg (checking http://example.com/video.mpeg) ok

If you don't trust the web to this degree, just let git-annex know:

# git annex untrust web
untrust web ok

With the result that it will hang onto files:

# git annex drop example.com_video.mpeg
drop example.com_video.mpeg (unsafe) 
  Could only verify the existence of 0 out of 1 necessary copies
  Also these untrusted repositories may contain the file:
    00000000-0000-0000-0000-000000000001  -- web
  (Use --force to override this check, or adjust annex.numcopies.)
failed

You can also add urls to any file already in the annex:

# git annex addurl --file my_cool_big_file http://example.com/cool_big_file
addurl my_cool_big_file ok
# git annex whereis my_cool_big_file
whereis my_cool_big_file (2 copies) 
00000000-0000-0000-0000-000000000001 -- web
27a9510c-760a-11e1-b9a0-c731d2b77df9 -- here

To add a lot of urls at once, just list them all as parameters to git annex addurl.

If you're adding a bunch of related files to a directory, or just don't like the default filenames generated by addurl, you can use --pathdepth to specify how many parts of the url are put in the filename. A positive number drops that many paths from the beginning, while a negative number takes that many paths from the end.

# git annex addurl http://example.com/videos/2012/01/video.mpeg
addurl example.com_videos_2012_01_video.mpeg (downloading http://example.com/videos/2012/01/video.mpeg)
# git annex addurl http://example.com/videos/2012/01/video.mpeg --pathdepth=2
addurl 2012_01_video.mpeg (downloading http://example.com/videos/2012/01/video.mpeg)
# git annex addurl http://example.com/videos/2012/01/video.mpeg --pathdepth=-2
addurl 01_video.mpeg (downloading http://example.com/videos/2012/01/video.mpeg)

There are resources that I want to add to my annex that are currently available via a URL, but it seems like if I add these using git-annex addurl, they get symlinked to file in the annex/objects directory that starts with URL-..., instead of the more typical SHA256-..., and this does not change even after the files are downloaded.

My concern is that I really want to ensure that these files don't change, which is the appeal of content-addressable symlinking of normal files (as opposed to URL addressable ones).

Would there be a way to automate the injection of hash-based symlinking for files that are added via addurl? Sometimes I add a bunch of files via addurl --fast, and after I've download them via get, it would be nice to have those files have the same level of data integrity as when I download them using something outside of git-annex, add them to the annex, and do an addurl --file afterward.

Thanks for all of your hard work!

addurl only uses the URL- keys if you run it with --fast. Otherwise it downloads the content and hashes it the same as add does.

If you use --fast, you can go back and git annex migrate the file once it's been downloaded, to convert it to the SHA backend.

Comment by http://joeyh.name/ Thu Sep 20 21:55:57 2012

is there a way to remove one of the urls? e.g. if I have

$> git annex whereis fail2ban_logo.png
whereis fail2ban_logo.png (1 copy) 
    00000000-0000-0000-0000-000000000001 -- web

  web: http://www.fail2ban.org/fail2ban_logo.png
  web: http://www.onerussian.com/tmp/statsmodes.png
ok

and would like to remove the fail2ban.org one... ?

You can use git annex rmurl $file $url, which I just added to git-annex.

(Also, git annex drop $file --from web will remove all the urls..)

Comment by http://joeyh.name/ Mon Apr 22 21:28:03 2013
Comments on this page are closed.