Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Fix channel iteration #5

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions indexer/src/directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def latest_request(directory, channel, target, file_type):
Args:
directory: Repository name
channel: Channel type (release, rc, dev)
target: Operation System (linux, mac, win)
target: Operating System (linux, mac, win)
file_type: File Type

Returns:
Expand All @@ -51,7 +51,7 @@ async def latest_request(directory, channel, target, file_type):
try:
return index.get_file_from_latest_version(channel, target, file_type)
except Exception as e:
return JSONResponse(e, status_code=404)
return JSONResponse(str(e), status_code=404)


@router.get("/{directory}/reindex")
Expand Down
2 changes: 1 addition & 1 deletion indexer/src/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def create_upload_files(
logging.info(f"Uploaded {len(files)} files")
except Exception as e:
logging.exception(e)
return JSONResponse(e, status_code=500)
return JSONResponse(str(e), status_code=500)
if is_directory_reindex_needed(branch):
try:
reindex_dir.reindex()
Expand Down
10 changes: 8 additions & 2 deletions indexer/src/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_file_from_latest_version(
current directory by its target and type
Args:
channel: Channel type (release, rc, dev)
target: Operation System (linux, mac, win)
target: Operating System (linux, mac, win)
file_type: File Type

Returns:
Expand All @@ -113,7 +113,13 @@ def get_file_from_latest_version(
target = target.replace("-", "/")
try:
channels = self.index["channels"]
current_channel = next(filter(lambda c: c.get("id") == channel, channels))
current_channel = next(
filter(lambda c: c.get("id") == channel, channels), None
)

if current_channel is None:
raise ValueError(f"Channel `{channel}` not found!")

latest_version = current_channel.get("versions")[0]
latest_version_file = next(
filter(
Expand Down