···5858 return # There are no currently unexpired files
59596060 # Calculate an expiration date for all existing files
6161- files = session.scalars(
6161+6262+ q = session.scalars(
6263 sa.select(File)
6364 .where(
6464- sa.not_(File.removed),
6565- File.sha256.in_(unexpired_files)
6565+ sa.not_(File.removed)
6666 )
6767 )
6868 updates = [] # We coalesce updates to the database here
6969+7070+ # SQLite has a hard limit on the number of variables so we
7171+ # need to do this the slow way
7272+ files = [f for f in q if f.sha256 in unexpired_files]
7373+6974 for file in files:
7075 file_path = storage / file.sha256
7176 stat = os.stat(file_path)