Skip to content

Commit a35e06d

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 f8f3534 commit a35e06d

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
@@ -939,15 +939,14 @@ def delete_all_posts(self, poster: User, *, deleter: User):
939939
# TODO: Eventually we can drop this: once uploads have to be properly associated with
940940
# posts then the post deletion should trigger automatic expiry of post attachments.
941941

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

0 commit comments

Comments
 (0)