Fix failure to make session cache folder on startup

This commit is contained in:
JonnyWong16 2018-02-15 12:21:44 -08:00
parent 93e4853ea2
commit 12755970b7
2 changed files with 12 additions and 5 deletions

View file

@ -165,9 +165,6 @@ def initialize(config_file):
except OSError as e: except OSError as e:
pass pass
if not os.path.exists(session_metadata_folder):
os.mkdir(session_metadata_folder)
# Initialize the database # Initialize the database
logger.info(u"Checking if the database upgrades are required...") logger.info(u"Checking if the database upgrades are required...")
try: try:

View file

@ -533,7 +533,12 @@ class PmsConnect(object):
metadata = {} metadata = {}
if cache_key: if cache_key:
in_file_path = os.path.join(plexpy.CONFIG.CACHE_DIR, 'session_metadata/metadata-sessionKey-%s.json' % cache_key) in_file_folder = os.path.join(plexpy.CONFIG.CACHE_DIR, 'session_metadata')
in_file_path = os.path.join(in_file_folder, 'metadata-sessionKey-%s.json' % cache_key)
if not os.path.exists(in_file_folder):
os.mkdir(in_file_folder)
try: try:
with open(in_file_path, 'r') as inFile: with open(in_file_path, 'r') as inFile:
metadata = json.load(inFile) metadata = json.load(inFile)
@ -1179,7 +1184,12 @@ class PmsConnect(object):
if cache_key: if cache_key:
metadata['_cache_time'] = int(time.time()) metadata['_cache_time'] = int(time.time())
out_file_path = os.path.join(plexpy.CONFIG.CACHE_DIR, 'session_metadata/metadata-sessionKey-%s.json' % cache_key) out_file_folder = os.path.join(plexpy.CONFIG.CACHE_DIR, 'session_metadata')
out_file_path = os.path.join(out_file_folder, 'metadata-sessionKey-%s.json' % cache_key)
if not os.path.exists(out_file_folder):
os.mkdir(out_file_folder)
try: try:
with open(out_file_path, 'w') as outFile: with open(out_file_path, 'w') as outFile:
json.dump(metadata, outFile) json.dump(metadata, outFile)