Skip to content

Commit

Permalink
#2040: Warn if no compiler files were found when exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Apr 15, 2024
1 parent 1be9a67 commit 990acb3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

# Bugfixes:
* Fix add-game prompt failing to appear if installed fresh.
* #2040: Warn if no compiler files were found when exporting.


------------------------------------------
Expand Down
44 changes: 26 additions & 18 deletions src/exporting/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
from app.gameMan import Game


TRANS_MISSING_FILE = TransToken.ui(
"Compiler file {file} missing. "
"You will need to verify the game's cache in Steam to get these files back. "
"You can then export again."
)
TRANS_PERMISSION_FAIL = TransToken.ui(
"Copying compiler file {file} failed. Ensure {game}'s map compiler is not running."
)
TRANS_PERMISSION_FAIL_ERROR_SERVER = TransToken.ui(
"Copying compiler file {file} failed. Ensure {game}'s map compiler is not running. "
'The webserver for the error display may also be running, quit the vrad process or'
' wait a few minutes.'
)
TRANS_NO_COMPILER_FILES = TransToken.ui(
'No compiler files were found in "{folder}".'
)


async def is_original_executable(file: trio.Path) -> bool:
"""Check if the given application is Valve's, or ours.
Expand Down Expand Up @@ -160,11 +178,7 @@ async def backup(description: str, item_path: trio.Path, backup_path: trio.Path)
await item_path.unlink()
except FileNotFoundError:
pass
raise AppError(TransToken.ui(
"Compiler file {file} missing. "
"You will need to verify the game's cache in Steam to get these files back. "
"You can then export again."
).format(file=item_path.name))
raise AppError(TRANS_MISSING_FILE.format(file=item_path.name))
# TODO: Trigger the messagebox for automatically validating.
# webbrowser.open('steam://validate/' + str(self.steamID))

Expand Down Expand Up @@ -209,23 +223,17 @@ def perform_copy(src: Path, dest: Path) -> None:
# running.
if exp_data.maybe_error_server_running:
# Use a different error if this might be running.
msg = TransToken.ui(
'Copying compiler file {file} failed. '
"Ensure {game}'s map compiler is not running. "
'The webserver for the error display may also be running, '
'quit the vrad process or wait a few minutes.'
)
msg = TRANS_PERMISSION_FAIL_ERROR_SERVER
else:
msg = TransToken.ui(
'Copying compiler file {file} failed. '
"Ensure {game}'s map compiler is not running."
)
msg = TRANS_PERMISSION_FAIL

raise AppError(msg.format(file=dest, game=exp_data.game.name)) from exc

async with trio.open_nursery() as nursery, utils.aclosing(
STAGE_COMPILER.iterate(list(compiler_src.rglob('*')))
) as agen:
files = list(compiler_src.rglob('*'))
if not files:
exp_data.warn(TRANS_NO_COMPILER_FILES.format(folder=compiler_src))

async with trio.open_nursery() as nursery, utils.aclosing(STAGE_COMPILER.iterate(files)) as agen:
async for comp_file in agen:
# Ignore folders.
if comp_file.is_dir():
Expand Down

0 comments on commit 990acb3

Please sign in to comment.