From 31bd5bdf5962b81cd22df5173775d7886405be80 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 31 Jul 2017 14:56:57 +0000 Subject: [PATCH 1/1] Track whether loading is underway In preparation for safeguards preventing alteration of elements from read-only backing files, we need a way to identify that loading updated files is in progress; that's the only time elements from read-only files should ever change. --- mudpy/misc.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mudpy/misc.py b/mudpy/misc.py index af5427a..4e32ccc 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -347,6 +347,7 @@ class Universe: self.contents = {} self.default_origins = {} self.directions = set() + self.loading = False self.loglines = [] self.private_files = [] self.reload_flag = False @@ -375,6 +376,9 @@ class Universe: def load(self): """Load universe data from persistent storage.""" + # while loading, it's safe to update elements from read-only files + self.loading = True + # it's possible for this to enter before logging configuration is read pending_loglines = [] @@ -425,6 +429,10 @@ class Universe: for element in self.contents.values(): element.update_location() element.clean_contents() + + # done loading, so disallow updating elements from read-only files + self.loading = False + return pending_loglines def new(self): -- 2.11.0