mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-05 23:56:37 +08:00
Fix circular import issue between config, logger, and helpers modules (#2)
* Initial plan * Fix circular import by removing top-level settings import from helpers.py Co-authored-by: bbbugg <80089841+bbbugg@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bbbugg <80089841+bbbugg@users.noreply.github.com>
This commit is contained in:
committed by
bbbugg
co-authored by
bbbugg
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
parent
bb6c629aef
commit
8711088ebc
+12
-8
@@ -10,7 +10,6 @@ from pathlib import Path
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from app.core.constants import DATA_URL_PATTERN, IMAGE_URL_PATTERN, VALID_IMAGE_RATIOS
|
from app.core.constants import DATA_URL_PATTERN, IMAGE_URL_PATTERN, VALID_IMAGE_RATIOS
|
||||||
from app.config.config import settings
|
|
||||||
|
|
||||||
helper_logger = logging.getLogger("app.utils")
|
helper_logger = logging.getLogger("app.utils")
|
||||||
|
|
||||||
@@ -193,16 +192,21 @@ def get_current_version(default_version: str = "0.0.0") -> str:
|
|||||||
|
|
||||||
|
|
||||||
def is_image_upload_configured() -> bool:
|
def is_image_upload_configured() -> bool:
|
||||||
"""Return True only if a valid upload provider is selected and all required settings for that provider are present."""
|
"""Return True only if a valid upload provider is selected and all required settings for that provider are present. Uses lazy import to avoid circular imports."""
|
||||||
provider = getattr(settings, "UPLOAD_PROVIDER", "").strip().lower()
|
try:
|
||||||
|
from app.config.config import settings # local import to avoid circular dependency at module import time
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
provider = (getattr(settings, "UPLOAD_PROVIDER", "") or "").strip().lower()
|
||||||
if provider == "smms":
|
if provider == "smms":
|
||||||
return bool(getattr(settings, "SMMS_SECRET_TOKEN", None))
|
return bool(getattr(settings, "SMMS_SECRET_TOKEN", ""))
|
||||||
if provider == "picgo":
|
if provider == "picgo":
|
||||||
return bool(getattr(settings, "PICGO_API_KEY", None))
|
return bool(getattr(settings, "PICGO_API_KEY", ""))
|
||||||
if provider == "cloudflare_imgbed":
|
if provider == "cloudflare_imgbed":
|
||||||
return all([
|
return all([
|
||||||
getattr(settings, "CLOUDFLARE_IMGBED_URL", None),
|
getattr(settings, "CLOUDFLARE_IMGBED_URL", ""),
|
||||||
getattr(settings, "CLOUDFLARE_IMGBED_AUTH_CODE", None),
|
getattr(settings, "CLOUDFLARE_IMGBED_AUTH_CODE", ""),
|
||||||
getattr(settings, "CLOUDFLARE_IMGBED_UPLOAD_FOLDER", None),
|
getattr(settings, "CLOUDFLARE_IMGBED_UPLOAD_FOLDER", ""),
|
||||||
])
|
])
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user