2 Commits

Author SHA1 Message Date
2fb2ffb2e1 server/posts: fix custom thumbnails 2025-03-27 02:31:47 +01:00
3f42037e2b server/posts: fix source file deletion 2025-03-27 02:27:42 +01:00
2 changed files with 5 additions and 5 deletions

View File

@ -25,8 +25,8 @@ def scan(path: str) -> List[Any]:
return []
def find(path: str, pattern: str) -> List[Any]:
return glob.glob(glob.escape(_get_full_path(path) + "/") + pattern)
def find(path: str, pattern: str, recursive: bool = False) -> List[Any]:
return glob.glob(glob.escape(_get_full_path(path) + "/") + pattern, recursive=recursive)
def move(source_path: str, target_path: str) -> None:

View File

@ -129,7 +129,7 @@ def get_post_custom_thumbnail_url(post: model.Post) -> str:
return "%s/generated-thumbnails/custom-thumbnails/sample_%d_%s.jpg" % (
config.config["data_url"].rstrip("/"),
post.post_id,
post.image_key,
get_post_security_hash(post.post_id),
)
@ -148,7 +148,7 @@ def get_post_custom_content_path(post: model.Post) -> str:
assert post.post_id
return "posts/custom-thumbnails/%d_%s.dat" % (
post.post_id,
post.image_key,
get_post_security_hash(post.post_id),
)
@ -481,7 +481,7 @@ def _before_post_delete(
) -> None:
if post.post_id:
if config.config["delete_source_files"]:
pattern = post.post_id + "_*"
pattern = f"{post.post_id}_*"
for file in files.find("posts", "**/" + pattern, recursive=True) + files.find("generated-thumbnails", "**/sample_" + pattern, recursive=True):
files.delete(file)