Skip to content

Commit

Permalink
staging: remove redundant exists() call (#6217)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Jun 23, 2021
1 parent dafe6e9 commit 53e9460
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 0 additions & 5 deletions dvc/objects/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ def get_file_hash(path_info, fs, name, state=None):
if hash_info:
return hash_info

if not fs.exists(path_info):
raise FileNotFoundError(
errno.ENOENT, os.strerror(errno.ENOENT), path_info
)

hash_info = _get_file_hash(path_info, fs, name)

if state:
Expand Down
6 changes: 3 additions & 3 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_warn_on_outdated_stage(tmp_dir, dvc, local_remote, caplog):

def test_hash_recalculation(mocker, dvc, tmp_dir, local_remote):
tmp_dir.gen({"foo": "foo"})
test_get_file_hash = mocker.spy(dvc_module.objects.stage, "_get_file_hash")
test_file_md5 = mocker.spy(dvc_module.objects.stage, "file_md5")
ret = main(["config", "cache.type", "hardlink"])
assert ret == 0
ret = main(["add", "foo"])
Expand All @@ -257,7 +257,7 @@ def test_hash_recalculation(mocker, dvc, tmp_dir, local_remote):
assert ret == 0
ret = main(["run", "--single-stage", "-d", "foo", "echo foo"])
assert ret == 0
assert test_get_file_hash.mock.call_count == 1
assert test_file_md5.mock.call_count == 1


def test_missing_cache(tmp_dir, dvc, local_remote, caplog):
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_verify_hashes(
remove("dir")
remove(dvc.odb.local.cache_dir)

hash_spy = mocker.spy(dvc_module.objects.stage, "_get_file_hash")
hash_spy = mocker.spy(dvc_module.objects.stage, "file_md5")

dvc.pull()
assert hash_spy.call_count == 0
Expand Down

0 comments on commit 53e9460

Please sign in to comment.