Skip to content

Commit

Permalink
Fix #65: ignore outdated databases during cleanup task
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Sep 5, 2022
1 parent 89c1015 commit 2ebb44e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/fief/tasks/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
WorkspaceRepository,
)
from fief.repositories.base import ExpiresAtMixin
from fief.services.workspace_db import WorkspaceDatabase
from fief.tasks.base import TaskBase

repository_classes: List[Type[ExpiresAtMixin]] = [
Expand All @@ -29,10 +30,13 @@ class CleanupTask(TaskBase):
__name__ = "cleanup"

async def run(self):
latest_revision = WorkspaceDatabase().get_latest_revision()
async with self.get_main_session() as session:
workspace_repository = WorkspaceRepository(session)
workspaces = await workspace_repository.all()
for workspace in workspaces:
if workspace.alembic_revision != latest_revision:
continue
try:
async with self.get_workspace_session(
workspace
Expand Down

0 comments on commit 2ebb44e

Please sign in to comment.