Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dvc/repo/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ def _cloud_status(
for info in status_info.values():
name = info["name"]
status_ = info["status"]
if status_ in [cloud.STATUS_OK, cloud.STATUS_MISSING]:
if status_ == cloud.STATUS_OK:
continue

prefix_map = {cloud.STATUS_DELETED: "deleted", cloud.STATUS_NEW: "new"}
prefix_map = {
cloud.STATUS_DELETED: "deleted",
cloud.STATUS_NEW: "new",
cloud.STATUS_MISSING: "missing",
}

ret[name] = prefix_map[status_]

Expand Down
25 changes: 23 additions & 2 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
from flaky.flaky_decorator import flaky

from dvc.cache import NamedCache
from dvc.cache.base import STATUS_DELETED, STATUS_NEW, STATUS_OK
from dvc.cache.base import (
STATUS_DELETED,
STATUS_MISSING,
STATUS_NEW,
STATUS_OK,
)
from dvc.external_repo import clean_repos
from dvc.main import main
from dvc.stage.exceptions import StageNotFound
from dvc.tree.local import LocalTree
from dvc.utils.fs import remove
from dvc.utils.fs import move, remove
from dvc.utils.yaml import dump_yaml, load_yaml

from .test_api import all_clouds
Expand Down Expand Up @@ -49,6 +54,22 @@ def test_cloud(tmp_dir, dvc, remote): # pylint:disable=unused-argument
expected = {md5_dir: {"name": md5_dir, "status": STATUS_NEW}}
assert status_dir == expected

# Move cache and check status
# See issue https://github.com/iterative/dvc/issues/4383 for details
backup_dir = dvc.cache.local.cache_dir + ".backup"
move(dvc.cache.local.cache_dir, backup_dir)
status = dvc.cloud.status(info, show_checksums=True)
expected = {md5: {"name": md5, "status": STATUS_MISSING}}
assert status == expected

status_dir = dvc.cloud.status(info_dir, show_checksums=True)
expected = {md5_dir: {"name": md5_dir, "status": STATUS_MISSING}}
assert status_dir == expected

# Restore original cache:
remove(dvc.cache.local.cache_dir)
move(backup_dir, dvc.cache.local.cache_dir)

# Push and check status
dvc.cloud.push(info)
assert os.path.exists(cache)
Expand Down