From fa22e5691705f5f5f07ec033307ad404116cd6cc Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 18 Mar 2018 12:35:56 +0200 Subject: [PATCH] state: use str representations for inode and mtime Signed-off-by: Ruslan Kuprieiev --- dvc/state.py | 17 +++++++++++++---- requirements.txt | 1 + setup.py | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dvc/state.py b/dvc/state.py index 2b143e581..38011873b 100644 --- a/dvc/state.py +++ b/dvc/state.py @@ -1,5 +1,6 @@ import os import json +import nanotime from checksumdir import dirhash from dvc.system import System @@ -70,9 +71,17 @@ class State(object): with open(self.state_file, 'w+') as fd: json.dump(self._db, fd) + @staticmethod + def mtime(path): + return str(int(nanotime.timestamp(os.path.getmtime(path)))) + + @staticmethod + def inode(path): + return str(System.inode(path)) + def update(self, path, dump=True): - mtime = os.path.getmtime(path) - inode = System.inode(path) + mtime = self.mtime(path) + inode = self.inode(path) md5 = self._get(inode, mtime) if md5: @@ -100,7 +109,7 @@ class State(object): return None def get(self, path): - mtime = os.path.getmtime(path) - inode = System.inode(path) + mtime = self.mtime(path) + inode = self.inode(path) return self._get(inode, mtime) diff --git a/requirements.txt b/requirements.txt index e04ae1d33..7190c72e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,4 @@ gitpython>=2.1.8 ntfsutils>=0.1.3 checksumdir>=1.1.4 setuptools>=34.0.0 +nanotime>=0.5.2 diff --git a/setup.py b/setup.py index d0604d5f3..865d3e373 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,7 @@ install_requires = [ "ntfsutils>=0.1.3", "checksumdir>=1.1.4", "setuptools>=34.0.0", + "nanotime>=0.5.2", ] setup(