mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Merge pull request #2060 from pared/rollback_1526
remote: local: roll back cache dir metadata storing
This commit is contained in:
@@ -38,8 +38,6 @@ from dvc.exceptions import DvcException
|
||||
from dvc.progress import progress
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from dvc.utils.fs import get_mtime_and_size, get_inode
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -495,22 +493,6 @@ class RemoteLOCAL(RemoteBASE):
|
||||
download=True,
|
||||
)
|
||||
|
||||
def _changed_dir_cache(self, checksum):
|
||||
mtime, size = get_mtime_and_size(self.cache_dir)
|
||||
inode = get_inode(self.cache_dir)
|
||||
|
||||
existing_record = self.state.get_state_record_for_inode(inode)
|
||||
if existing_record:
|
||||
cached_mtime, cached_size, _, _ = existing_record
|
||||
changed = not (mtime == cached_mtime and size == cached_size)
|
||||
else:
|
||||
changed = True
|
||||
|
||||
if not changed:
|
||||
return False
|
||||
|
||||
return super(RemoteLOCAL, self)._changed_dir_cache(checksum)
|
||||
|
||||
def _log_missing_caches(self, checksum_info_dict):
|
||||
missing_caches = [
|
||||
(md5, info)
|
||||
|
||||
@@ -269,8 +269,6 @@ class State(StateBase): # pylint: disable=too-many-instance-attributes
|
||||
)
|
||||
)
|
||||
|
||||
self._update_cache_directory_state()
|
||||
|
||||
self.database.commit()
|
||||
self.cursor.close()
|
||||
self.database.close()
|
||||
@@ -458,20 +456,3 @@ class State(StateBase): # pylint: disable=too-many-instance-attributes
|
||||
for relpath in unused:
|
||||
cmd = 'DELETE FROM {} WHERE path = "{}"'
|
||||
self._execute(cmd.format(self.LINK_STATE_TABLE, relpath))
|
||||
|
||||
def _update_cache_directory_state(self):
|
||||
cache_path = self.repo.cache.local.cache_dir
|
||||
mtime, size = get_mtime_and_size(cache_path)
|
||||
inode = get_inode(cache_path)
|
||||
|
||||
cmd = (
|
||||
"INSERT OR REPLACE INTO {}(inode, size, mtime, timestamp, md5) "
|
||||
'VALUES ({}, "{}", "{}", "{}", "")'.format(
|
||||
self.STATE_TABLE,
|
||||
self._to_sqlite(inode),
|
||||
size,
|
||||
mtime,
|
||||
current_timestamp(),
|
||||
)
|
||||
)
|
||||
self._execute(cmd)
|
||||
|
||||
@@ -325,29 +325,6 @@ class TestAddCommit(TestDvc):
|
||||
self.assertEqual(len(os.listdir(self.dvc.cache.local.cache_dir)), 1)
|
||||
|
||||
|
||||
class TestShouldNotCheckCacheForDirIfCacheMetadataDidNotChange(TestDvc):
|
||||
def test(self):
|
||||
remote_local_loader_spy = spy(
|
||||
dvc.remote.local.RemoteLOCAL.load_dir_cache
|
||||
)
|
||||
with patch.object(
|
||||
dvc.remote.local.RemoteLOCAL,
|
||||
"load_dir_cache",
|
||||
remote_local_loader_spy,
|
||||
):
|
||||
|
||||
ret = main(["config", "cache.type", "copy"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
ret = main(["add", self.DATA_DIR])
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(1, remote_local_loader_spy.mock.call_count)
|
||||
|
||||
ret = main(["status", "{}.dvc".format(self.DATA_DIR)])
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(1, remote_local_loader_spy.mock.call_count)
|
||||
|
||||
|
||||
class TestShouldCollectDirCacheOnlyOnce(TestDvc):
|
||||
def test(self):
|
||||
from dvc.remote.local import RemoteLOCAL
|
||||
|
||||
Reference in New Issue
Block a user