summaryrefslogtreecommitdiff
path: root/migrations/versions
diff options
context:
space:
mode:
authorMia Herkt <mia@0x0.st>2022-12-20 14:23:14 +0100
committerMia Herkt <mia@0x0.st>2022-12-20 14:23:14 +0100
commitdcea8bffe19b8ba308f9361d6c8ef08281ddff1b (patch)
tree655d59e8d05503a5e586272e3dcd456f832fb823 /migrations/versions
parentf76dbef82fbaf916c3d42b50bd89046af0f784a5 (diff)
migrations: Fix file expirations on SQLite
Well that was what we feared. I love arbitrary hardcoded limits.
Diffstat (limited to 'migrations/versions')
-rw-r--r--migrations/versions/939a08e1d6e5_.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/migrations/versions/939a08e1d6e5_.py b/migrations/versions/939a08e1d6e5_.py
index f86dcb3..e389b41 100644
--- a/migrations/versions/939a08e1d6e5_.py
+++ b/migrations/versions/939a08e1d6e5_.py
@@ -58,14 +58,19 @@ def upgrade():
return # There are no currently unexpired files
# Calculate an expiration date for all existing files
- files = session.scalars(
+
+ q = session.scalars(
sa.select(File)
.where(
- sa.not_(File.removed),
- File.sha256.in_(unexpired_files)
+ sa.not_(File.removed)
)
)
updates = [] # We coalesce updates to the database here
+
+ # SQLite has a hard limit on the number of variables so we
+ # need to do this the slow way
+ files = [f for f in q if f.sha256 in unexpired_files]
+
for file in files:
file_path = storage / file.sha256
stat = os.stat(file_path)