Skip to content

The only downloader you need. 下载器的集大成者。

fix: 开机启动后 Feature Pack 加载失败

XiaoYouChRba25397116d0
diff --git a/app/services/feature_service.py b/app/services/feature_service.py
index 8d765836..97038aeb 100644
--- a/app/services/feature_service.py
+++ b/app/services/feature_service.py
@@ -9,6 +9,7 @@ from loguru import logger
from app.bases.interfaces import FeaturePack
from app.bases.models import Task
+from app.supports.paths import executableDir
if TYPE_CHECKING:
from app.view.components.cards import ParseSettingCard
@@ -18,7 +19,7 @@ if TYPE_CHECKING:
class FeatureService:
def __init__(self):
self._packs: dict[str, FeaturePack] = {}
- self._featuresPath = Path(__file__).parent.parent.parent / "features"
+ self._featuresPath = executableDir / "features"
def _sortedPacks(self) -> list[tuple[str, FeaturePack]]:
items = list(self._packs.items())
diff --git a/app/supports/paths.py b/app/supports/paths.py
index e4f1405b..07242bcc 100644
--- a/app/supports/paths.py
+++ b/app/supports/paths.py
@@ -3,9 +3,13 @@ from pathlib import Path
from PySide6.QtCore import QStandardPaths
-_executableDir = Path(sys.argv[0]).resolve().parent
+executableDir = (
+ Path(sys.executable).resolve().parent
+ if "__compiled__" in globals()
+ else Path(".")
+)
APP_DATA_DIR: str = (
- str(_executableDir / "GhostDownloader")
- if (_executableDir / "GhostDownloader").is_dir()
+ str(executableDir / "GhostDownloader")
+ if (executableDir / "GhostDownloader").is_dir()
else f"{QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericDataLocation)}/GhostDownloader"
)