mirror of
https://git.srhtnin.garden/sarah/SaraSort.git
synced 2026-10-13 18:28:18 +02:00
Directory configs outside their directories (SaraSortd 7.2)
SaraSort finds configs and history files where SaraSortd 7.2 keeps them (DirConfDir, [DirConfs]), and Settings > SaraSortd moves the existing ones between "inside each directory" and one folder. Imports keep [DirConfs] entries with moved directories, and Warnings flag a config folder inside an input or a SaraSortd older than 7.2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
edc2832a0f
commit
28252e3101
5 files changed
+177
-20
No files matched your search
+51
@@ -112,6 +112,49 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[], None]) -> None:
|
||||
|
||||
SortdFileField = ft.TextField(value=str(Home / "SaraSortd-Configs.toml"), label="SaraSortd export file path")
|
||||
|
||||
# Where directory configs live (SaraSortd 7.2's DirConfDir), like SaraTag's Lexicons folder.
|
||||
try:
|
||||
CurrentSetup = Setup(Config)
|
||||
CurrentFolder = str(CurrentSetup.Dirs.get("DirConfDir", "") or "")
|
||||
except SortdError:
|
||||
CurrentSetup, CurrentFolder = None, ""
|
||||
LocationPicker = ft.RadioGroup(
|
||||
ft.Row([
|
||||
ft.Radio(value="Inside", label="Inside each directory"),
|
||||
ft.Radio(value="Folder", label="In one folder"),
|
||||
]),
|
||||
value="Folder" if CurrentFolder else "Inside",
|
||||
disabled=CurrentSetup is None,
|
||||
)
|
||||
FolderRow, FolderField = DirField(TheApp, "Config folder (relative paths count from GlobalConf.toml's folder)",
|
||||
CurrentFolder or "Dirs")
|
||||
FolderRow.visible = bool(CurrentFolder)
|
||||
|
||||
def OnLocationChanged(e) -> None:
|
||||
FolderRow.visible = LocationPicker.value == "Folder"
|
||||
FolderRow.update()
|
||||
|
||||
LocationPicker.on_change = OnLocationChanged
|
||||
|
||||
def OnMoveConfs(e) -> None:
|
||||
NewFolder = (FolderField.value or "").strip() if LocationPicker.value == "Folder" else ""
|
||||
if LocationPicker.value == "Folder" and not NewFolder:
|
||||
TheApp.Notify("Pick a folder for the configs.", "warning")
|
||||
return
|
||||
if NewFolder == CurrentFolder:
|
||||
TheApp.Notify("The configs are already there.", "info")
|
||||
return
|
||||
try:
|
||||
Moved = Setup(Config).MoveDirConfs(NewFolder)
|
||||
except (OSError, SortdError) as Error:
|
||||
TheApp.Notify(f"Couldn't move the configs: {Error}", "error")
|
||||
return
|
||||
Page.pop_dialog()
|
||||
OnSaved()
|
||||
TheApp.AfterGlobalChange()
|
||||
TheApp.Notify(f"Moved {Moved} file{'s' if Moved != 1 else ''}; directory configs now live "
|
||||
f"{'in ' + NewFolder if NewFolder else 'inside each directory'}.", "success")
|
||||
|
||||
def OnSortdExport(e) -> None:
|
||||
PathText = (SortdFileField.value or "").strip()
|
||||
if not PathText:
|
||||
@@ -206,6 +249,14 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[], None]) -> None:
|
||||
RefreshField,
|
||||
LogLinesField,
|
||||
ft.Divider(height=1, color=Palette.Surface1),
|
||||
_Note("Where SaraSortd keeps each directory's config (and history file). In one folder, the "
|
||||
"directories stay clean; each config is named after its directory, e.g. "
|
||||
"Pictures_CatsConfig.toml. Needs SaraSortd 7.2. Moving takes the existing configs along."),
|
||||
LocationPicker,
|
||||
FolderRow,
|
||||
ft.OutlinedButton(content="Move configs", style=ChipButtonStyle(), on_click=OnMoveConfs,
|
||||
disabled=CurrentSetup is None),
|
||||
ft.Divider(height=1, color=Palette.Surface1),
|
||||
_Note("Export/import all of SaraSortd's configs as one file: GlobalConf.toml, both templates "
|
||||
"and every input/output directory's own config. Importing replaces the current ones "
|
||||
"(they're backed up first)."),
|
||||
|
||||
Reference in new issue
Block a user