Skip to content

Commit 6e5948c

Browse files
committed
Updated checkpoint id
1 parent 746cd6c commit 6e5948c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

version_manager/qt_history_widget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def __init__(self, utils):
5151
[
5252
key,
5353
self._history[key]["thumbnail"],
54-
"{}\n{}".format(self._history[key]["date"], key),
54+
# "{}\n{}".format(self._history[key]["date"], key),
55+
"{}\n{}".format(self._history[key]["date"], self._history[key]["id"]),
5556
ast.literal_eval(self._history[key]["message"]),
5657
]
5758
for key in reversed(sorted(self._history))

version_manager/utils.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import errno
77
import json
88
import os
9+
import random
910
import shutil
1011
from datetime import datetime
1112

@@ -235,6 +236,14 @@ def add_checkpoint(self, msg=""):
235236
# date_string += f"\n{mod_date}"
236237
date_file = mod_date.strftime("%Y_%m_%d__%H_%M_%S_%f")
237238

239+
self.lock_history()
240+
self.read_history()
241+
242+
short_id = 0
243+
while short_id in [int(self.history[entry]["id"]) for entry in self.history]:
244+
short_id += 1
245+
short_id = "{:04}".format(short_id)
246+
238247
# name of directory to hold checkpoint data
239248
dirname = f"doc__{date_file}"
240249
doc_dir = os.path.join(self.data_dir, dirname)
@@ -243,10 +252,8 @@ def add_checkpoint(self, msg=""):
243252
os.path.basename(self.krita_filename)
244253
)
245254

246-
checkpoint_filename = f"{filename_base}__{date_file}{filename_ext}"
247-
248-
self.lock_history()
249-
self.read_history()
255+
# checkpoint_filename = f"{filename_base}__{date_file}{filename_ext}"
256+
checkpoint_filename = f"{filename_base}__{short_id}{filename_ext}"
250257

251258
# quit if an entry for this timestamp already exists
252259
if dirname in self.history:
@@ -283,6 +290,7 @@ def add_checkpoint(self, msg=""):
283290
("message", repr(msg)),
284291
("date", date_string),
285292
("owner", owner),
293+
("id", short_id),
286294
):
287295
self.history[doc_id][key] = value
288296

0 commit comments

Comments
 (0)