dvc: move temporary files to .dvc/tmp (#3725)

Fixes #3666
This commit is contained in:
Ruslan Kuprieiev
2020-05-03 18:42:12 +03:00
committed by GitHub
parent 3e1eb6d1e7
commit 4e9b38970a
8 changed files with 15 additions and 24 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ class CmdBase(object):
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
+2 -1
View File
@@ -15,9 +15,10 @@ class CmdDaemonUpdater(CmdDaemonBase):
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
+1 -1
View File
@@ -17,7 +17,7 @@ DEFAULT_TIMEOUT = 5
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."
)
+3 -11
View File
@@ -93,8 +93,8 @@ class Repo(object):
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 @@ class Repo(object):
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]
+2 -3
View File
@@ -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 @@ class State(object): # pylint: disable=too-many-instance-attributes
"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 = [
+3 -4
View File
@@ -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,
)
+1 -1
View File
@@ -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"
+2 -2
View File
@@ -8,7 +8,7 @@ from tests.basic_env import TestDvc
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 @@ class TestLock(TestDvc):
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])