-
-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Fix url download function #2744
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,7 +416,7 @@ def read_links(html: str, base: str) -> set[str]: | |
async def download_urls( | ||
bucket_dir: Path, | ||
urls: list[str], | ||
max_depth: int = 1, | ||
max_depth: int = 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting |
||
loading_urls: set[str] = set(), | ||
lock: asyncio.Lock = None, | ||
delay: int = 3, | ||
|
@@ -515,7 +515,7 @@ def stream_chunks(bucket_dir: Path, delete_files: bool = False, refine_chunks_wi | |
if refine_chunks_with_spacy: | ||
for chunk in stream_read_parts_and_refine(bucket_dir, delete_files): | ||
if event_stream: | ||
size += len(chunk.decode('utf-8')) | ||
size += len(chunk.encode()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
yield f'data: {json.dumps({"action": "refine", "size": size})}\n\n' | ||
else: | ||
yield chunk | ||
|
@@ -524,7 +524,7 @@ def stream_chunks(bucket_dir: Path, delete_files: bool = False, refine_chunks_wi | |
streaming = cache_stream(streaming, bucket_dir) | ||
for chunk in streaming: | ||
if event_stream: | ||
size += len(chunk.decode('utf-8')) | ||
size += len(chunk.encode()) | ||
hlohaus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
yield f'data: {json.dumps({"action": "load", "size": size})}\n\n' | ||
else: | ||
yield chunk | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from a global case-insensitive match to a format enforcing regex using
^
and$
is correct for checking if the entire string is a URL. However, thegi
flags for global and case-insensitive search remain. Theg
flag seems unnecessary as the intention appears to be validating a single URL string, not matching multiple occurrences. Consider removing theg
flag to simplify the regex.