api: enter state when trying to get a hash (#4584)

`get_hash` is an internal api, so conventions should be respected.

Fixes #4575
This commit is contained in:
Ruslan Kuprieiev
2020-09-21 23:37:51 +03:00
committed by GitHub
parent ff3b686058
commit cf5d461f4d
2 changed files with 5 additions and 1 deletions
+2 -1
View File
@@ -34,7 +34,8 @@ def get_url(path, repo=None, rev=None, remote=None):
raise OutputNotFoundError(path, repo)
cloud = metadata.repo.cloud
hash_info = _repo.repo_tree.get_hash(path_info)
with _repo.state:
hash_info = _repo.repo_tree.get_hash(path_info)
return cloud.get_url_for(remote, checksum=hash_info.value)
+3
View File
@@ -210,6 +210,9 @@ def test_get_url_granular(tmp_dir, dvc, s3):
{"dir": {"foo": "foo", "bar": "bar", "nested": {"file": "file"}}}
)
expected_url = URLInfo(s3.url) / "5f/c28ea78987408341668eba6525ebd1.dir"
assert api.get_url("dir") == expected_url
expected_url = URLInfo(s3.url) / "ac/bd18db4cc2f85cedef654fccc4a4d8"
assert api.get_url("dir/foo") == expected_url