checkout: use os.path.samefile instead of stat

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2017-10-30 05:05:28 +02:00
parent 52b47a25b4
commit 299e4e2ae1
2 changed files with 8 additions and 5 deletions
+1 -5
View File
@@ -1,5 +1,4 @@
import os
from stat import ST_INO, ST_DEV
from dvc.command.base import CmdBase, DvcLock
from dvc.logger import Logger
@@ -17,10 +16,7 @@ class CmdCheckout(CmdBase):
if not os.path.isfile(data) or not os.path.isfile(cache):
return False
data_st = os.stat(data)
cache_st = os.stat(cache)
if (data_st[ST_INO], data_st[ST_DEV]) != (cache_st[ST_INO], cache_st[ST_DEV]):
if not System.samefile(data, cache):
return False
return True
+7
View File
@@ -23,6 +23,13 @@ class System(object):
raise Exception('Not Implemented Yet')
@staticmethod
def samefile(path1, path2):
if System.is_unix():
return os.path.samefile(path1, path2)
raise Exception('Not Implemented Yet')
@staticmethod
def realpath(path):
# It is definitely not the best way to check a symlink.