Skip to content

Commit

Permalink
BUGFIX:
Browse files Browse the repository at this point in the history
- Scheduler: load mission_file did not work if full path was provided
  • Loading branch information
karel26 committed Jan 21, 2025
1 parent 863ee2d commit aab9e47
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
20 changes: 10 additions & 10 deletions plugins/scheduler/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,20 +303,20 @@ async def restart_mission(self, server: Server, config: dict, rconf: dict, max_w
try:
mission_id = rconf.get('mission_id')
if not mission_id:
filename = rconf.get('mission_file')
else:
filename = None
if not mission_id and not filename:
self.log.error("You need to provide either mission_id or filename to your load configuration!")
return
filename = utils.format_string(filename, instance=server.instance, server=server)
if not mission_id:
filename = utils.format_string(rconf.get('mission_file'),
instance=server.instance, server=server)
if not filename:
self.log.error(
"You need to provide either mission_id or mission_file to your load configuration!")
return
if not os.path.isabs(filename):
filename = os.path.join(await server.get_missions_dir(), filename)
for idx, mission in enumerate(await server.getMissionList()):
if os.path.basename(mission).lower() == filename.lower():
if os.path.normpath(mission).lower() == os.path.normpath(filename).lower():
mission_id = idx + 1
break
else:
self.log.error(f"No mission with name {filename} found in your serverSettings.lua!")
self.log.error(f"Mission {filename} not found in your serverSettings.lua!")
return
self.log.debug(f"Scheduler: Loading mission {mission_id} on server {server.name} ...")
modify_mission = rconf.get('run_extensions', True)
Expand Down
13 changes: 11 additions & 2 deletions plugins/scheduler/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,17 @@ async def process(self, server: Server, what: dict) -> None:
asyncio.create_task(self.bot.audit(f"{self.plugin_name.title()} rotated to mission "
f"{server.current_mission.display_name}", server=server))
elif what['command'] == 'load':
if not await server.loadMission(what.get('mission_id', what.get('mission_file'))):
self.log.warning(f"Mission {server.current_mission.display_name} NOT loaded.")
if 'mission_id' in what:
_mission = what['mission_id']
elif 'mission_file' in what:
_mission = what['mission_file']
if not os.path.isabs(_mission):
_mission = os.path.join(await server.get_missions_dir(), _mission)
else:
self.log.error(f"No mission_id or mission_file specified in {what}")
return
if not await server.loadMission(_mission):
self.log.warning(f"Mission {_mission} NOT loaded.")
else:
message = f'loaded mission {server.current_mission.display_name}'
if 'user' not in what:
Expand Down

0 comments on commit aab9e47

Please sign in to comment.