Skip to content
Merged
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
31 changes: 30 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,44 @@
urls_to_fetch = [u for u in urls if u not in _cache and validate_folder_url(u)]
if not urls_to_fetch:
return
log.info(f"Warming up cache for {len(urls_to_fetch)} URLs...")

total = len(urls_to_fetch)
if not USE_COLORS:
log.info(f"Warming up cache for {total} URLs...")

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions

completed = 0
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = {executor.submit(_gh_get, url): url for url in urls_to_fetch}

if USE_COLORS:
sys.stderr.write(f"\r{Colors.CYAN}⏳ Warming up cache: 0/{total}...{Colors.ENDC}")
sys.stderr.flush()

for future in concurrent.futures.as_completed(futures):
completed += 1
if USE_COLORS:
sys.stderr.write(f"\r{Colors.CYAN}⏳ Warming up cache: {completed}/{total}...{Colors.ENDC}")

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (107/100) Warning

Line too long (107/100)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (111/100) Warning

Line too long (111/100)
sys.stderr.flush()

try:
future.result()
except Exception as e:
if USE_COLORS:
# Clear line to print warning cleanly
sys.stderr.write("\r\033[K")
sys.stderr.flush()

log.warning(f"Failed to pre-fetch {sanitize_for_log(futures[future])}: {e}")

if USE_COLORS:
# Restore progress
sys.stderr.write(f"\r{Colors.CYAN}⏳ Warming up cache: {completed}/{total}...{Colors.ENDC}")

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (111/100) Warning

Line too long (111/100)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (107/100) Warning

Line too long (107/100)
sys.stderr.flush()

if USE_COLORS:
sys.stderr.write(f"\r{Colors.GREEN}✅ Warming up cache: {total}/{total} Done! {Colors.ENDC}\n")

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (106/100) Warning

Line too long (106/100)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (106/100) Warning

Line too long (106/100)
sys.stderr.flush()

def delete_folder(client: httpx.Client, profile_id: str, name: str, folder_id: str) -> bool:
try:
_api_delete(client, f"{API_BASE}/{profile_id}/groups/{folder_id}")
Expand Down
Loading