Skip to content

Commit

Permalink
style: improve code flow and move comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiosantoscode committed Jan 10, 2020
1 parent 0dd5647 commit 07637a6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions dvc/repo/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def get(url, path, out=None, rev=None):
try:
cached_clone(url, rev=rev, clone_path=tmp_dir)
try:
repo = Repo(tmp_dir)

# Try any links possible to avoid data duplication.
#
# Not using symlink, because we need to remove cache after we are
Expand All @@ -60,21 +62,23 @@ def get(url, path, out=None, rev=None):
#
# Also, we can't use theoretical "move" link type here, because
# the same cache file might be used a few times in a directory.
repo = Repo(tmp_dir)
repo.cache.local.cache_types = ["reflink", "hardlink", "copy"]

output = repo.find_out_by_relpath(path)
if not output.use_cache:
if output.use_cache:
# Catch this below and go for a plain old fs_copy
raise _DoPlainCopy
_get_cached(repo, output, out)
_get_cached(repo, output, out)
return

except (NotDvcRepoError, OutputNotFoundError):
pass

except (NotDvcRepoError, OutputNotFoundError, _DoPlainCopy):
# It's an uncached out with absolute path, a non-DVC repo, or a
# user error
if os.path.isabs(path):
raise FileNotFoundError
# It's an uncached out with absolute path, a non-DVC repo, or a
# user error
if os.path.isabs(path):
raise FileNotFoundError

fs_copy(os.path.join(tmp_dir, path), out)
fs_copy(os.path.join(tmp_dir, path), out)

except (OutputNotFoundError, FileNotFoundError):
raise PathMissingError(path, url)
Expand Down

0 comments on commit 07637a6

Please sign in to comment.