Don't worry about modified time - only check hash for changes

This commit is contained in:
CorpNewt
2024-11-07 20:46:10 -06:00
committed by GitHub
parent e55b170296
commit 7718801a71
+6 -12
View File
@@ -418,7 +418,6 @@ class PlistWindow(tk.Toplevel):
# Set up the options
self.current_plist = None # None = new
self.last_saved = None
self.last_hash = None
self.edited = False
self.dragging = False
@@ -2314,19 +2313,16 @@ class PlistWindow(tk.Toplevel):
if event and event.widget == self:
self.lift()
if self.controller.settings.get("warn_if_modified",True) \
and self.current_plist and os.path.isfile(self.current_plist) \
and self.last_saved and self.last_hash:
# We have a valid file and a save time - see if the file
and self.current_plist and os.path.isfile(self.current_plist) and self.last_hash:
# We have a valid file - see if the file
# has been modified since then
try:
last_modified = os.path.getmtime(self.current_plist)
modified_hash = self.get_hash(self.current_plist)
except Exception:
self.last_saved = self.last_hash = None
self.last_hash = None
return
if self.last_saved != last_modified and self.last_hash != modified_hash:
if self.last_hash != modified_hash:
# Update to avoid continually warning
self.last_saved = last_modified
self.last_hash = modified_hash
self.bell()
if mb.askyesno(
@@ -2675,10 +2671,9 @@ class PlistWindow(tk.Toplevel):
# Retain the new path if the save worked correctly
self.current_plist = path
try:
self.last_saved = os.path.getmtime(path)
self.last_hash = save_hash
except Exception:
self.last_saved = self.last_hash = None # Reset them
self.last_hash = None # Reset them
# Set the window title to the path
self.title(path)
# No changes - so we'll reset that
@@ -2692,10 +2687,9 @@ class PlistWindow(tk.Toplevel):
self.add_node(plist_data,check_binary=plist_type.lower() == "binary")
self.current_plist = os.path.normpath(path) if path else path
try:
self.last_saved = os.path.getmtime(path)
self.last_hash = self.get_hash(path)
except Exception:
self.last_saved = self.last_hash = None
self.last_hash = None
if path is None:
self._ensure_edited(title=title or "Untitled.plist")
else: