Fix deletion of files in panopticon

This commit is contained in:
Ruben van de Ven 2019-05-06 08:13:13 +02:00
parent 0861215794
commit f4eb5afb46
2 changed files with 14 additions and 4 deletions

View File

@ -195,4 +195,13 @@ Types of conditions:
TODO
times occured/only on n-th instance: determines the order of diversions of the same type (for Timeout and no_response). Starting at 1, as a diversion with value of 0 can occur always
times occured/only on n-th instance: determines the order of diversions of the same type (for Timeout and no_response). Starting at 1, as a diversion with value of 0 can occur always
# Network
## 4G Modem
Visit 192.168.5.1
The password is at the bottom of the device.

View File

@ -152,7 +152,7 @@ def getUploadHandler(central_command):
self.finish()
def post(self):
print('upload')
logger.info('upload')
langCode = self.get_argument("language")
langFile = os.path.join(central_command.config['web']['files_dir'] , central_command.languageFiles[langCode])
@ -171,7 +171,7 @@ def getUploadHandler(central_command):
for i, data in enumerate(storyData):
if data['@id'] != msgId:
continue
if 'audio' in storyData[i] and os.path.exists(storyData[i]['audio']['file']):
if 'audio' in storyData[i] and storyData[i]['audio'] is not None and os.path.exists(storyData[i]['audio']['file']):
logger.info(f"Remove previous file {storyData[i]['audio']['file']} ({storyData[i]['audio']['original_name']})")
os.unlink(storyData[i]['audio']['file'])
@ -184,7 +184,8 @@ def getUploadHandler(central_command):
fp.write(audioFile['body'])
break
print(os.path.abspath(langFile))
# logger.info(os.path.abspath(langFile))
langFile = os.path.abspath(langFile)
with open(langFile, 'w') as json_fp:
logger.info(f'Save story to {langFile} {json_fp}')
json.dump(storyData, json_fp, indent=2)