added simple cache to getDataDir
This commit is contained in:
parent
22cda74bb9
commit
2b8e7076b4
1 changed files with 15 additions and 0 deletions
15
ostools.py
15
ostools.py
|
@ -8,6 +8,7 @@ except ImportError:
|
|||
print("PyQt5 fallback (ostools.py)")
|
||||
from PyQt5.QtCore import QStandardPaths
|
||||
|
||||
DATADIR = None
|
||||
|
||||
def isOSX():
|
||||
return sys.platform == "darwin"
|
||||
|
@ -75,6 +76,18 @@ def getDataDir():
|
|||
# Temporary fix for non-ascii usernames
|
||||
# If username has non-ascii characters, just store userdata
|
||||
# in the Pesterchum install directory (like before)
|
||||
|
||||
if DATADIR is not None:
|
||||
# ~Lisanne
|
||||
# On some systems (windows known 2b affected, OSX unknown, at least 1 linux distro unaffected)
|
||||
# the QStandardPaths.writableLocation changes its return path after the QApplication initialises
|
||||
# This means that anytime its called during runtime after init will just return a lie. it will just give you a different path
|
||||
# (Because the Application now has a Name which in turn makes it return an application-name-specific writableLocation, which pchum isnt expecting anywhere)
|
||||
# so
|
||||
# here im caching the result at init & returning that
|
||||
# seemed like the safest way to do this without breaking half of this program
|
||||
return DATADIR
|
||||
|
||||
try:
|
||||
if isOSX():
|
||||
return os.path.join(
|
||||
|
@ -100,3 +113,5 @@ def getDataDir():
|
|||
except UnicodeDecodeError as e:
|
||||
print(e)
|
||||
return ""
|
||||
|
||||
DATADIR = getDataDir()
|
Loading…
Reference in a new issue