diff --git a/dvc/command/checkout.py b/dvc/command/checkout.py index 153a6b4cc..b135642ab 100644 --- a/dvc/command/checkout.py +++ b/dvc/command/checkout.py @@ -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 diff --git a/dvc/system.py b/dvc/system.py index bb4d41acc..55f61ccc9 100644 --- a/dvc/system.py +++ b/dvc/system.py @@ -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.