Commit 9ae2e000 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Use readable timestamp and node name in conflict file

parent fb628ecc
......@@ -99,9 +99,28 @@ def file_is_open(path):
return False
def is_iso_date(tstamp):
try:
datetime.datetime.strptime(tstamp, "%Y-%m-%dT%H:%M:%S.%f")
return True
except ValueError:
return False
def get_orig_name(filename):
parts = filename.split('_')
if len(parts) < 3 or parts[-1] != utils.NODE or not is_iso_date(parts[-2]):
return filename
orig = "_".join(parts[:-2])
if not orig:
return filename
return orig
def mk_stash_name(filename):
tstamp = datetime.datetime.now().strftime("%s")
return filename + '.' + tstamp + '.local'
tstamp = datetime.datetime.now().isoformat()
orig = get_orig_name(filename)
return orig + '_' + tstamp + '_' + utils.NODE
def eq_float(f1, f2):
......
......@@ -20,6 +20,7 @@ import threading
import watchdog.utils
import sys
import logging
import platform
logger = logging.getLogger(__name__)
......@@ -27,6 +28,7 @@ from agkyra.syncer.common import OBJECT_DIRSEP
ENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding()
PLATFORM = sys.platform
NODE = platform.node()
def to_local_sep(filename):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment