diff --git a/dvc/command/base.py b/dvc/command/base.py index 30f8700c7a..21838a9227 100644 --- a/dvc/command/base.py +++ b/dvc/command/base.py @@ -36,7 +36,7 @@ def __init__(self, args): self.config = self.repo.config self.args = args hardlink_lock = self.config["core"].get("hardlink_lock", False) - updater = Updater(self.repo.dvc_dir, hardlink_lock=hardlink_lock) + updater = Updater(self.repo.tmp_dir, hardlink_lock=hardlink_lock) updater.check() @property diff --git a/dvc/command/daemon.py b/dvc/command/daemon.py index cb03b3a37b..63854d35f8 100644 --- a/dvc/command/daemon.py +++ b/dvc/command/daemon.py @@ -15,9 +15,10 @@ def run(self): root_dir = Repo.find_root() dvc_dir = os.path.join(root_dir, Repo.DVC_DIR) + tmp_dir = os.path.join(dvc_dir, "tmp") config = Config(dvc_dir, validate=False) hardlink_lock = config.get("core", {}).get("hardlink_lock", False) - updater = Updater(dvc_dir, hardlink_lock=hardlink_lock) + updater = Updater(tmp_dir, hardlink_lock=hardlink_lock) updater.fetch(detach=False) return 0 diff --git a/dvc/lock.py b/dvc/lock.py index a9d39b46e7..3be226b6dc 100644 --- a/dvc/lock.py +++ b/dvc/lock.py @@ -17,7 +17,7 @@ FAILED_TO_LOCK_MESSAGE = ( "cannot perform the command because another DVC process seems to be " "running on this project. If that is not the case, manually remove " - "`.dvc/lock` and try again." + "`.dvc/tmp/lock` and try again." ) diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index b9c38f575c..fed09b2f29 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -93,8 +93,8 @@ def __init__(self, root_dir=None): hardlink_lock = self.config["core"].get("hardlink_lock", False) self.lock = make_lock( - os.path.join(self.dvc_dir, "lock"), - tmp_dir=os.path.join(self.dvc_dir, "tmp"), + os.path.join(self.tmp_dir, "lock"), + tmp_dir=self.tmp_dir, hardlink_lock=hardlink_lock, friendly=True, ) @@ -164,15 +164,7 @@ def unprotect(self, target): return self.cache.local.unprotect(PathInfo(target)) def _ignore(self): - from dvc.updater import Updater - - updater = Updater(self.dvc_dir) - - flist = ( - [self.config.files["local"], updater.updater_file] - + [self.lock.lockfile, updater.lock.lockfile, self.tmp_dir] - + self.state.files - ) + flist = [self.config.files["local"], self.tmp_dir] if path_isin(self.cache.local.cache_dir, self.root_dir): flist += [self.cache.local.cache_dir] diff --git a/dvc/state.py b/dvc/state.py index 22881daff8..b515748be2 100644 --- a/dvc/state.py +++ b/dvc/state.py @@ -96,7 +96,6 @@ class State(object): # pylint: disable=too-many-instance-attributes def __init__(self, repo): self.repo = repo - self.dvc_dir = repo.dvc_dir self.root_dir = repo.root_dir state_config = repo.config.get("state", {}) @@ -105,11 +104,11 @@ def __init__(self, repo): "row_cleanup_quota", self.STATE_ROW_CLEANUP_QUOTA ) - if not self.dvc_dir: + if not repo.tmp_dir: self.state_file = None return - self.state_file = os.path.join(self.dvc_dir, self.STATE_FILE) + self.state_file = os.path.join(repo.tmp_dir, self.STATE_FILE) # https://www.sqlite.org/tempfiles.html self.temp_files = [ diff --git a/dvc/updater.py b/dvc/updater.py index cfa416ffa8..d3d2636660 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -21,12 +21,11 @@ class Updater(object): # pragma: no cover TIMEOUT = 24 * 60 * 60 # every day TIMEOUT_GET = 10 - def __init__(self, dvc_dir, friendly=False, hardlink_lock=False): - self.dvc_dir = dvc_dir - self.updater_file = os.path.join(dvc_dir, self.UPDATER_FILE) + def __init__(self, tmp_dir, friendly=False, hardlink_lock=False): + self.updater_file = os.path.join(tmp_dir, self.UPDATER_FILE) self.lock = make_lock( self.updater_file + ".lock", - tmp_dir=os.path.join(dvc_dir, "tmp"), + tmp_dir=tmp_dir, friendly=friendly, hardlink_lock=hardlink_lock, ) diff --git a/tests/func/test_diff.py b/tests/func/test_diff.py index 96776d6fe2..707b4936bd 100644 --- a/tests/func/test_diff.py +++ b/tests/func/test_diff.py @@ -39,7 +39,7 @@ def test_no_cache_entry(tmp_dir, scm, dvc): tmp_dir.dvc_gen("file", "second") remove(fspath(tmp_dir / ".dvc" / "cache")) - (tmp_dir / ".dvc" / "state").unlink() + (tmp_dir / ".dvc" / "tmp" / "state").unlink() dir_checksum = "5fb6b29836c388e093ca0715c872fe2a.dir" diff --git a/tests/func/test_lock.py b/tests/func/test_lock.py index ccf71fedfd..61e4671731 100644 --- a/tests/func/test_lock.py +++ b/tests/func/test_lock.py @@ -8,7 +8,7 @@ class TestLock(TestDvc): def test_with(self): - lockfile = os.path.join(self.dvc.dvc_dir, "lock") + lockfile = os.path.join(self.dvc.dvc_dir, "tmp", "lock") lock = Lock(lockfile) with lock: with self.assertRaises(LockError): @@ -17,7 +17,7 @@ def test_with(self): self.assertTrue(False) def test_cli(self): - lockfile = os.path.join(self.dvc.dvc_dir, "lock") + lockfile = os.path.join(self.dvc.dvc_dir, "tmp", "lock") lock = Lock(lockfile) with lock: ret = main(["add", self.FOO])