From 6aeccfcc07aa0b0037d57f4c76faaf4edcb66c6b Mon Sep 17 00:00:00 2001 From: Alexander Schepanovski Date: Wed, 4 Sep 2019 15:24:36 +0700 Subject: [PATCH] dvc: fix long lock filenames under Windows --- dvc/lock.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dvc/lock.py b/dvc/lock.py index 40ecc3093..32a4f460c 100644 --- a/dvc/lock.py +++ b/dvc/lock.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import os from datetime import timedelta +import hashlib from flufl.lock import Lock as _Lock, TimeOutError from dvc.exceptions import DvcException @@ -57,5 +58,6 @@ class Lock(_Lock): super(Lock, self)._set_claimfile(pid) if self._tmp_dir is not None: - filename = self._claimfile.replace(os.sep, "_") - self._claimfile = os.path.join(self._tmp_dir, filename) + # Under Windows file path length is limited so we hash it + filename = hashlib.md5(self._claimfile.encode()).hexdigest() + self._claimfile = os.path.join(self._tmp_dir, filename + ".lock")