From: Jeremy Stanley Date: Sat, 29 Jul 2017 18:24:06 +0000 (+0000) Subject: Fix file pathing in daemon mode X-Git-Tag: 0.0.1~147 X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=commitdiff_plain;h=275b3f156a8ceb0ec50e5651cbcb8415269c7dd4;hp=947a707d32fe29eff85c7091b82be5c67056aecf Fix file pathing in daemon mode If run as a daemon, the working directory is reset to "/" for safety. Make sure that relative file searching takes this into account and prefixes with the original (pre-chdir) start directory rather than the current working directory. --- diff --git a/mudpy/data.py b/mudpy/data.py index 8b7e731..c4848be 100644 --- a/mudpy/data.py +++ b/mudpy/data.py @@ -247,16 +247,18 @@ def find_file( "internal:storage", "").get("search_path", "") # another fallback root path, this time from the universe startdir - if not root_path and hasattr(universe, "startdir"): - root_path = universe.startdir + if hasattr(universe, "startdir"): + if not root_path: + root_path = universe.startdir + elif not os.path.isabs(root_path): + root_path = os.path.join(universe.startdir, root_path) # when no root path is specified, assume the current working directory if not root_path: root_path = os.getcwd() - # otherwise, make sure it's absolute - elif not os.path.isabs(root_path): - root_path = os.path.realpath(root_path) + # make sure it's absolute + root_path = os.path.realpath(root_path) # if there's no search path, just use the root path and etc if not search_path: