forked from mia/0x0
migrations: Fix file expirations on SQLite
Well that was what we feared. I love arbitrary hardcoded limits.
This commit is contained in:
parent
f76dbef82f
commit
dcea8bffe1
1 changed files with 8 additions and 3 deletions
|
@ -58,14 +58,19 @@ def upgrade():
|
||||||
return # There are no currently unexpired files
|
return # There are no currently unexpired files
|
||||||
|
|
||||||
# Calculate an expiration date for all existing files
|
# Calculate an expiration date for all existing files
|
||||||
files = session.scalars(
|
|
||||||
|
q = session.scalars(
|
||||||
sa.select(File)
|
sa.select(File)
|
||||||
.where(
|
.where(
|
||||||
sa.not_(File.removed),
|
sa.not_(File.removed)
|
||||||
File.sha256.in_(unexpired_files)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
updates = [] # We coalesce updates to the database here
|
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:
|
for file in files:
|
||||||
file_path = storage / file.sha256
|
file_path = storage / file.sha256
|
||||||
stat = os.stat(file_path)
|
stat = os.stat(file_path)
|
||||||
|
|
Loading…
Reference in a new issue