liberapay / git-lfs-fetch.py

Lightweight Git Large File Storage fetcher written in python
31 stars 13 forks source link

FileNotFoundError #1

Closed bdewilde closed 8 years ago

bdewilde commented 8 years ago

Hey, I've tried to use this package both from the command line and as a Python library, but in both cases get a FileNotFoundError:

$ python -m git_lfs path/to/repo path/to/another/dir
Downloading <filename> (<filesize> bytes) from https://github-cloud.s3.amazonaws.com/al...
Traceback (most recent call last):
  File "/Users/burtondewilde/.pyenv/versions/3.5.1/lib/python3.5/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/burtondewilde/.pyenv/versions/3.5.1/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/burtondewilde/.pyenv/versions/3.5.1/lib/python3.5/site-packages/git_lfs/__main__.py", line 14, in <module>
    fetch(args.git_repo, args.checkout_dir, args.verbose)
  File "/Users/burtondewilde/.pyenv/versions/3.5.1/lib/python3.5/site-packages/git_lfs/__init__.py", line 184, in fetch
    force_link(dst1, dst2)
  File "/Users/burtondewilde/.pyenv/versions/3.5.1/lib/python3.5/site-packages/git_lfs/utils.py", line 57, in force_link
    os.link(source, link_name)
FileNotFoundError: [Errno 2] No such file or directory: 'path/to/repo/.git/lfs/objects/c0/57/c05745c4a7564988bcc0396492dcb39f678a2c467c867d515d8733f9c7d58749' -> 'path/to/another/dir/<filename>'

I assume it's user error, but can't figure out what I'm doing wrong. Any help would be much appreciated! Thanks.

Changaco commented 8 years ago

Which one is missing? Is it the source file (path/to/repo/.git/lfs/objects/c0/57/c05745c4a7564988bcc0396492dcb39f678a2c467c867d515d8733f9c7d58749) or the destination folder (path/to/another/dir/)?

bdewilde commented 8 years ago

The source file exists ā€” there's a binary file at that location whose contents I can indeed see. So it must have been an issue with the destination folder.

In fact, after trying a bunch of things, I got this to work by creating a subdirectory structure under the destination folder that exactly matched that in the repo. That was unexpected to me, but maybe a deliberate design decision on your part! A couple usage examples might clarify everything, I was probably just misunderstanding your intended use. šŸ˜…

Thanks for the quick response!

Changaco commented 8 years ago

The checkout_dir is supposed to be an existing checkout of the git repo, so the code is built on the assumption that the sub-directories already exist.

A pull request to add support for downloading all the files in a single flat directory is welcome, if that's your use case. :-)