Skip to content

Commit 71a51be

Browse files
committed
fix: fix driver not saving cache data properly
1 parent c2a0576 commit 71a51be

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

tagstudio/src/core/settings/tssettings.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ def to_dict(self) -> dict[str, any]:
4040
return d
4141

4242
def save(self, path: Path | str | None = None) -> None:
43+
path_value: Path
4344
if isinstance(path, str):
44-
path = Path(path)
45+
path_value = Path(path)
4546

4647
if path is None:
47-
path = self.filename
48-
if not path.parent.exists():
49-
path.parent.mkdir(parents=True, exist_ok=True)
48+
path_value = Path(self.filename)
49+
if not path_value.parent.exists():
50+
path_value.parent.mkdir(parents=True, exist_ok=True)
5051

51-
with open(path, "w") as f:
52+
with open(path_value, "w") as f:
5253
toml.dump(self.to_dict(), f)

tagstudio/src/core/tscacheddata.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import toml
66
from appdirs import user_cache_dir
77
from pydantic import BaseModel, ConfigDict, Field
8-
from src.core.library.alchemy.library import Library
98

109
logger = structlog.get_logger(__name__)
1110

@@ -15,7 +14,7 @@
1514

1615
class TSCachedData(BaseModel):
1716
model_config = ConfigDict(arbitrary_types_allowed=True)
18-
last_library: Library | None = Field(default=None)
17+
last_library: str | None = Field(default=None)
1918
library_history: dict[datetime, str] = Field(default_factory=dict[datetime, str])
2019

2120
path: str = Field()
@@ -41,5 +40,5 @@ def open(path: str | None = None) -> "TSCachedData":
4140
return cached_data
4241

4342
def save(self):
44-
with open(self.path, "wb") as f:
45-
f.writelines(toml.dumps(self))
43+
with open(self.path, "w") as f:
44+
toml.dump(dict(self), f)

tagstudio/src/qt/ts_qt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ def handle_sigterm(self):
572572
def shutdown(self):
573573
"""Save Library on Application Exit."""
574574
self.close_library(is_shutdown=True)
575+
self.cache.save()
575576
logger.info("[SHUTDOWN] Ending Thumbnail Threads...")
576577
for _ in self.thumb_threads:
577578
self.thumb_job_queue.put(Consumer.MARKER_QUIT)

tagstudio/src/qt/widgets/preview_panel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ def __init__(self, library: Library, driver: "QtDriver"):
250250
# set initial visibility based on settings
251251
if not self.driver.settings.show_library_list:
252252
self.libs_flow_container.hide()
253+
else:
254+
self.libs_flow_container.show()
253255

254256
splitter = QSplitter()
255257
splitter.setOrientation(Qt.Orientation.Vertical)

0 commit comments

Comments
 (0)