7
7
from urllib .parse import urlencode , urlunparse
8
8
9
9
from dvc .exceptions import DvcException
10
+ from dvc .scm .tree import WorkingTree
10
11
from dvc .utils import current_timestamp , relpath , to_chunks
11
12
from dvc .utils .fs import get_inode , get_mtime_and_size , remove
12
13
@@ -91,6 +92,7 @@ class State: # pylint: disable=too-many-instance-attributes
91
92
def __init__ (self , repo ):
92
93
self .repo = repo
93
94
self .root_dir = repo .root_dir
95
+ self .tree = WorkingTree (self .root_dir )
94
96
95
97
state_config = repo .config .get ("state" , {})
96
98
self .row_limit = state_config .get ("row_limit" , self .STATE_ROW_LIMIT )
@@ -364,9 +366,7 @@ def save(self, path_info, checksum):
364
366
assert checksum is not None
365
367
assert os .path .exists (path_info )
366
368
367
- actual_mtime , actual_size = get_mtime_and_size (
368
- path_info , self .repo .tree
369
- )
369
+ actual_mtime , actual_size = get_mtime_and_size (path_info , self .tree )
370
370
actual_inode = get_inode (path_info )
371
371
372
372
existing_record = self .get_state_record_for_inode (actual_inode )
@@ -397,7 +397,7 @@ def get(self, path_info):
397
397
if not os .path .exists (path ):
398
398
return None
399
399
400
- actual_mtime , actual_size = get_mtime_and_size (path , self .repo . tree )
400
+ actual_mtime , actual_size = get_mtime_and_size (path , self .tree )
401
401
actual_inode = get_inode (path )
402
402
403
403
existing_record = self .get_state_record_for_inode (actual_inode )
@@ -423,7 +423,7 @@ def save_link(self, path_info):
423
423
if not os .path .exists (path_info ):
424
424
return
425
425
426
- mtime , _ = get_mtime_and_size (path_info , self .repo . tree )
426
+ mtime , _ = get_mtime_and_size (path_info , self .tree )
427
427
inode = get_inode (path_info )
428
428
relative_path = relpath (path_info , self .root_dir )
429
429
@@ -450,7 +450,7 @@ def get_unused_links(self, used):
450
450
continue
451
451
452
452
actual_inode = get_inode (path )
453
- actual_mtime , _ = get_mtime_and_size (path , self .repo . tree )
453
+ actual_mtime , _ = get_mtime_and_size (path , self .tree )
454
454
455
455
if (inode , mtime ) == (actual_inode , actual_mtime ):
456
456
logger .debug ("Removing '%s' as unused link." , path )
0 commit comments