Skip to content

Commit 3906619

Browse files
committed
Don't set room to null for expired images
Expiring them (also changed here to 0, rather that current time) is enough to make them inaccessible now.
1 parent c532eca commit 3906619

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sogs/model/room.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -936,15 +936,14 @@ def delete_all_posts(self, poster: User, *, deleter: User):
936936
# TODO: Eventually we can drop this: once uploads have to be properly associated with
937937
# posts then the post deletion should trigger automatic expiry of post attachments.
938938

939-
# Don't actually delete right now but set room to NULL so that the images aren't
940-
# retrievable, and set expiry to now so that they'll be picked up by the next db
941-
# cleanup.
939+
# Don't actually delete right now but just expire them so that the next db cleanup will
940+
# perform the deletion (and since they are expired, they won't be accessible in the
941+
# meantime).
942942
result = query(
943943
f"""
944-
UPDATE files SET room = NULL, expiry = :now WHERE room = :r AND uploader = :u
944+
UPDATE files SET expiry = 0.0 WHERE room = :r AND uploader = :u
945945
{'AND id != :omit' if omit_id else ''}
946946
""",
947-
now=time.time(),
948947
r=self.id,
949948
u=poster.id,
950949
omit=omit_id,

0 commit comments

Comments
 (0)