Skip to content

Commit

Permalink
Add logging for the LL update reason
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackenmen committed Mar 30, 2024
1 parent 72b7096 commit 50ee512
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions redbot/cogs/audio/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,29 +604,22 @@ async def _is_up_to_date(self):
stdout = (await _proc.communicate())[0]
if (branch := LAVALINK_BRANCH_LINE.search(stdout)) is None:
# Output is unexpected, suspect corrupted jarfile
return False
raise ValueError("Could not find 'Branch' line in the `--version` output.")
if (java := LAVALINK_JAVA_LINE.search(stdout)) is None:
# Output is unexpected, suspect corrupted jarfile
return False
raise ValueError("Could not find 'JVM' line in the `--version` output.")
if (lavaplayer := LAVALINK_LAVAPLAYER_LINE.search(stdout)) is None:
# Output is unexpected, suspect corrupted jarfile
return False
raise ValueError("Could not find 'Lavaplayer' line in the `--version` output.")
if (buildtime := LAVALINK_BUILD_TIME_LINE.search(stdout)) is None:
# Output is unexpected, suspect corrupted jarfile
return False
raise ValueError("Could not find 'Build time' line in the `--version` output.")

if (build := LAVALINK_BUILD_LINE.search(stdout)) is not None:
try:
self._lavalink_version = LavalinkOldVersion.from_version_output(stdout)
except ValueError:
# Output is unexpected, suspect corrupted jarfile
return False
else:
try:
self._lavalink_version = LavalinkVersion.from_version_output(stdout)
except ValueError:
# Output is unexpected, suspect corrupted jarfile
return False
self._lavalink_version = (
LavalinkOldVersion.from_version_output(stdout)
if LAVALINK_BUILD_LINE.search(stdout) is not None
else LavalinkVersion.from_version_output(stdout)
)
date = buildtime["build_time"].decode()
date = date.replace(".", "/")
self._lavalink_branch = branch["branch"].decode()
Expand All @@ -637,7 +630,24 @@ async def _is_up_to_date(self):
return self._up_to_date

async def maybe_download_jar(self):
if not (self.lavalink_jar_file.exists() and await self._is_up_to_date()):
if not self.lavalink_jar_file.exists():
log.info("Triggering first-time download of Lavalink...")
await self._download_jar()
return

try:
up_to_date = await self._is_up_to_date()
except ValueError as exc:
log.warning("Failed to get Lavalink version: %s\nTriggering update...", exc)
await self._download_jar()
return

if not up_to_date:
log.info(
"Lavalink version outdated, triggering update from %s to %s...",
self._lavalink_version,
self.JAR_VERSION
)
await self._download_jar()

async def wait_until_ready(self, timeout: Optional[float] = None):
Expand Down

0 comments on commit 50ee512

Please sign in to comment.