fixed file naming thingy
This commit is contained in:
@@ -132,12 +132,38 @@ def load_scheduled_tasks():
|
||||
"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
tasks = db.query(ScheduledTask).filter(ScheduledTask.enabled == True).all()
|
||||
# Check if the required columns exist before querying
|
||||
try:
|
||||
# First, check if we can access the table at all
|
||||
db.query(ScheduledTask).first()
|
||||
|
||||
# Try to query with the new columns - this will fail if columns don't exist
|
||||
tasks = db.query(ScheduledTask).filter(ScheduledTask.enabled == True).all()
|
||||
except Exception as column_error:
|
||||
if "no such column" in str(column_error):
|
||||
logger.warning(f"Database schema is outdated. Required columns missing: {column_error}")
|
||||
logger.info("Attempting to upgrade database schema...")
|
||||
|
||||
# Try to upgrade the database
|
||||
try:
|
||||
from .database import upgrade_database_schema
|
||||
upgrade_database_schema()
|
||||
|
||||
# Now try again to load tasks
|
||||
tasks = db.query(ScheduledTask).filter(ScheduledTask.enabled == True).all()
|
||||
logger.info("Database upgraded successfully, continuing with task loading")
|
||||
except Exception as upgrade_error:
|
||||
logger.error(f"Failed to upgrade database: {upgrade_error}")
|
||||
logger.info("Skipping scheduled task loading until database is manually upgraded")
|
||||
return
|
||||
else:
|
||||
raise
|
||||
|
||||
logger.info(f"Loading {len(tasks)} enabled scheduled tasks")
|
||||
|
||||
|
||||
for task in tasks:
|
||||
schedule_task(task)
|
||||
|
||||
|
||||
logger.info(f"Loaded {len(tasks)} scheduled tasks")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to load scheduled tasks: {e}", exc_info=True)
|
||||
@@ -198,8 +224,15 @@ async def execute_scheduled_task(task_id: str):
|
||||
'time_filter': 'day', # Always "day" for daily scheduled tasks
|
||||
'no_dupes': True, # Always enabled for scheduled tasks
|
||||
'simple_check': task.simple_check,
|
||||
'auth_state': task.auth_state
|
||||
'auth_state': task.auth_state,
|
||||
'upvoted': task.upvoted,
|
||||
'saved': task.saved
|
||||
}
|
||||
|
||||
# For user downloads, set submitted appropriately
|
||||
if task.source_type == 'user':
|
||||
# For likes or saved, don't download submitted posts
|
||||
kwargs['submitted'] = not (task.upvoted or task.saved)
|
||||
|
||||
# Create download using existing API
|
||||
download_id = await create_download_with_bdfr_api(
|
||||
|
||||
Reference in New Issue
Block a user