Skip to content

Commit

Permalink
checkout: always confirm link type
Browse files Browse the repository at this point in the history
Currently whether or not link confirmation will run depends on
particular filesystem and existing workspace link type, which introduces
inconsistency in behaviour, where we sometimes catch unsupported links
before touching user data and sometimes we don't.
  • Loading branch information
efiop committed Oct 27, 2021
1 parent 7c9dc68 commit 15b1169
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dvc/objects/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ def _link(cache, from_info, to_info):
raise CheckoutError([str(to_info)]) from exc


def _cache_is_copy(cache, path_info):
def _confirm_cache_type(cache, path_info):
"""Checks whether cache uses copies."""
if cache.cache_type_confirmed:
return cache.cache_types[0] == "copy"
return

if set(cache.cache_types) <= {"copy"}:
return True
return

workspace_file = path_info.with_name("." + uuid())
test_cache_file = cache.path_info / ".cache_type_test_file"
Expand All @@ -118,7 +118,6 @@ def _cache_is_copy(cache, path_info):
cache.fs.remove(test_cache_file)

cache.cache_type_confirmed = True
return cache.cache_types[0] == "copy"


def _relink(cache, cache_info, fs, path_info, in_cache, force):
Expand All @@ -143,10 +142,13 @@ def _checkout_file(
):
"""The file is changed we need to checkout a new copy"""
modified = False

_confirm_cache_type(cache, path_info)

cache_info = cache.hash_to_path_info(change.new.oid.value)
if change.old.oid:
if relink:
if fs.iscopy(path_info) and _cache_is_copy(cache, path_info):
if fs.iscopy(path_info) and cache.cache_types[0] == "copy":
cache.unprotect(path_info)
else:
_relink(
Expand Down

0 comments on commit 15b1169

Please sign in to comment.