Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/tagstudio/core/library/alchemy/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,10 @@ def has_path_entry(self, path: Path) -> bool:
with Session(self.engine) as session:
return session.query(exists().where(Entry.path == path)).scalar()

def all_paths(self) -> Iterable[tuple[int, Path]]:
with Session(self.engine) as session:
return ((i, p) for i, p in session.execute(select(Entry.id, Entry.path)).all())

def get_paths(self, limit: int = -1) -> list[str]:
path_strings: list[str] = []
with Session(self.engine) as session:
Expand Down Expand Up @@ -1170,6 +1174,23 @@ def update_entry_path(self, entry_id: int | Entry, path: Path) -> bool:
session.commit()
return True

def update_entry_paths(self, paths: Iterable[tuple[int, Path]]) -> bool:
"""Set the path field of many entries.

Returns True if the action succeeded and False if any path already exists.
"""
with Session(self.engine) as session:
for entry_id, new_path in paths:
stmt = update(Entry).where(Entry.id == entry_id).values(path=new_path)
session.execute(stmt)
try:
session.commit()
except IntegrityError as e:
logger.error(e)
session.rollback()
return False
return True

def remove_tag(self, tag_id: int) -> bool:
with Session(self.engine, expire_on_commit=False) as session:
try:
Expand Down
94 changes: 0 additions & 94 deletions src/tagstudio/core/library/alchemy/registries/unlinked_registry.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/tagstudio/core/library/ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

logger = structlog.get_logger()

PATH_GLOB_FLAGS = glob.GLOBSTARLONG | glob.DOTGLOB | glob.NEGATE | pathlib.MATCHBASE
PATH_GLOB_FLAGS = glob.GLOBSTARLONG | glob.DOTGLOB | glob.NEGATE | pathlib.MATCHBASE | pathlib.NODIR


GLOBAL_IGNORE = [
Expand Down
Loading