29 lines
981 B
Python
29 lines
981 B
Python
"""Read the initial project in a worker, never touching widgets or settings."""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from PySide6.QtCore import QObject, QRunnable, Signal
|
|
|
|
from .document_tree import discover_documents, document_directory_signature
|
|
|
|
|
|
class ScanSignals(QObject):
|
|
finished = Signal(object)
|
|
|
|
|
|
class StartupScan(QRunnable):
|
|
def __init__(self, generation: int, root: Path, groups: tuple[str, ...]) -> None:
|
|
super().__init__()
|
|
self.generation, self.root, self.groups = generation, root, groups
|
|
self.signals = ScanSignals()
|
|
|
|
def run(self) -> None:
|
|
try:
|
|
entries = discover_documents(self.root, self.groups)
|
|
signature = document_directory_signature(self.root, self.groups)
|
|
result = (entries, signature, None)
|
|
except Exception as exc:
|
|
result = ([], (), str(exc))
|
|
self.signals.finished.emit((self.generation, self.root, self.groups, *result))
|