mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-09-20 17:38:52 +02:00
Compare commits
3 Commits
695b3923c9
..
v9.5.7
| Author | SHA1 | Date | |
|---|---|---|---|
| cbb2d8d342 | |||
| 735bf072b0 | |||
| 6c8d800598 |
@@ -48,17 +48,17 @@ jobs:
|
||||
macos:
|
||||
strategy:
|
||||
matrix:
|
||||
os-version: ['13', '14']
|
||||
os-version: ['14', '15']
|
||||
include:
|
||||
- os-version: '13'
|
||||
arch: x86_64
|
||||
- os-version: '14'
|
||||
arch: x86_64
|
||||
- os-version: '15'
|
||||
arch: aarch64
|
||||
|
||||
runs-on: macos-${{ matrix.os-version }}
|
||||
|
||||
env:
|
||||
# INFO: Even though we run on 13, target towards compatibility
|
||||
# INFO: Even though we run on 14, target towards compatibility
|
||||
MACOSX_DEPLOYMENT_TARGET: '11.0'
|
||||
|
||||
steps:
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
||||
[project]
|
||||
name = "TagStudio"
|
||||
description = "A User-Focused Photo & File Management System."
|
||||
version = "9.5.6"
|
||||
version = "9.5.7"
|
||||
license = "GPL-3.0-only"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12,<3.13"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Licensed under the GPL-3.0 License.
|
||||
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
|
||||
|
||||
VERSION: str = "9.5.6" # Major.Minor.Patch
|
||||
VERSION: str = "9.5.7" # Major.Minor.Patch
|
||||
VERSION_BRANCH: str = "" # Usually "" or "Pre-Release"
|
||||
|
||||
# The folder & file names where TagStudio keeps its data relative to a library.
|
||||
|
||||
@@ -42,6 +42,7 @@ from sqlalchemy import (
|
||||
text,
|
||||
update,
|
||||
)
|
||||
from sqlalchemy.dialects import sqlite
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import (
|
||||
InstanceState,
|
||||
@@ -1478,7 +1479,7 @@ class Library:
|
||||
return None
|
||||
|
||||
def add_tags_to_entries(
|
||||
self, entry_ids: int | list[int] | set[int], tag_ids: int | list[int] | set[int]
|
||||
self, entry_ids: int | Iterable[int], tag_ids: int | Iterable[int]
|
||||
) -> int:
|
||||
"""Add one or more tags to one or more entries.
|
||||
|
||||
@@ -1494,45 +1495,57 @@ class Library:
|
||||
|
||||
entry_ids_ = [entry_ids] if isinstance(entry_ids, int) else entry_ids
|
||||
tag_ids_ = [tag_ids] if isinstance(tag_ids, int) else tag_ids
|
||||
values: list[tuple[int, int]] = []
|
||||
for tag_id in tag_ids_:
|
||||
values.extend((tag_id, entry_id) for entry_id in entry_ids_)
|
||||
|
||||
with Session(self.engine, expire_on_commit=False) as session:
|
||||
for tag_id in tag_ids_:
|
||||
for entry_id in entry_ids_:
|
||||
try:
|
||||
session.add(TagEntry(tag_id=tag_id, entry_id=entry_id))
|
||||
total_added += 1
|
||||
session.commit()
|
||||
except IntegrityError:
|
||||
session.rollback()
|
||||
for sub_list in [
|
||||
values[i : i + MAX_SQL_VARIABLES // 2]
|
||||
for i in range(0, len(values), MAX_SQL_VARIABLES // 2)
|
||||
]:
|
||||
stmt = (
|
||||
sqlite.insert(TagEntry)
|
||||
.values(sub_list)
|
||||
.on_conflict_do_nothing()
|
||||
.returning(TagEntry)
|
||||
)
|
||||
added = session.scalars(stmt).all()
|
||||
total_added += len(added)
|
||||
session.commit()
|
||||
|
||||
return total_added
|
||||
|
||||
def remove_tags_from_entries(
|
||||
self, entry_ids: int | list[int] | set[int], tag_ids: int | list[int] | set[int]
|
||||
) -> bool:
|
||||
self, entry_ids: int | Iterable[int], tag_ids: int | Iterable[int]
|
||||
):
|
||||
"""Remove one or more tags from one or more entries."""
|
||||
entry_ids_ = [entry_ids] if isinstance(entry_ids, int) else entry_ids
|
||||
tag_ids_ = [tag_ids] if isinstance(tag_ids, int) else tag_ids
|
||||
logger.info(
|
||||
"[Library][remove_tags_from_entries]",
|
||||
entry_ids=entry_ids,
|
||||
tag_ids=tag_ids,
|
||||
)
|
||||
|
||||
entry_ids_ = [entry_ids] if isinstance(entry_ids, int) else list(entry_ids)
|
||||
tag_ids_ = [tag_ids] if isinstance(tag_ids, int) else list(tag_ids)
|
||||
|
||||
with Session(self.engine, expire_on_commit=False) as session:
|
||||
try:
|
||||
for tag_id in tag_ids_:
|
||||
for entry_id in entry_ids_:
|
||||
tag_entry = session.scalars(
|
||||
select(TagEntry).where(
|
||||
and_(
|
||||
TagEntry.tag_id == tag_id,
|
||||
TagEntry.entry_id == entry_id,
|
||||
)
|
||||
)
|
||||
).first()
|
||||
if tag_entry:
|
||||
session.delete(tag_entry)
|
||||
session.flush()
|
||||
session.commit()
|
||||
return True
|
||||
except IntegrityError as e:
|
||||
logger.error(e)
|
||||
session.rollback()
|
||||
return False
|
||||
for tags_sub_list in [
|
||||
tag_ids_[i : i + MAX_SQL_VARIABLES // 2]
|
||||
for i in range(0, len(tag_ids_), MAX_SQL_VARIABLES // 2)
|
||||
]:
|
||||
for entries_sub_list in [
|
||||
entry_ids_[i : i + MAX_SQL_VARIABLES // 2]
|
||||
for i in range(0, len(entry_ids_), MAX_SQL_VARIABLES // 2)
|
||||
]:
|
||||
stmt = delete(TagEntry).where(
|
||||
and_(
|
||||
TagEntry.tag_id.in_(tags_sub_list),
|
||||
TagEntry.entry_id.in_(entries_sub_list),
|
||||
)
|
||||
)
|
||||
session.execute(stmt)
|
||||
session.commit()
|
||||
|
||||
def add_color(self, color_group: TagColorGroup) -> TagColorGroup | None:
|
||||
with Session(self.engine, expire_on_commit=False) as session:
|
||||
|
||||
Reference in New Issue
Block a user