fixed metadata time import error and moved quest status widget to top of settings.
This commit is contained in:
-71
@@ -490,55 +490,6 @@ def settings():
|
||||
return render_template('settings.html')
|
||||
|
||||
|
||||
@main.route('/trigger-thumbnail-generation', methods=['POST'])
|
||||
def trigger_thumbnail_generation():
|
||||
try:
|
||||
with open('/import/thumbnail.flag', 'w') as f:
|
||||
f.write("trigger")
|
||||
flash("Thumbnail regeneration has been triggered.", "success")
|
||||
except Exception as e:
|
||||
flash(f"Failed to trigger thumbnail regeneration: {e}", "danger")
|
||||
|
||||
return redirect(url_for('main.settings'))
|
||||
|
||||
|
||||
@main.route('/import-images')
|
||||
def trigger_image_import():
|
||||
with open('/import/trigger.flag', 'w') as f:
|
||||
f.write('start')
|
||||
flash("Image import triggered.", "success")
|
||||
return redirect(url_for('main.settings'))
|
||||
|
||||
|
||||
@main.route('/reset-db', methods=['POST'])
|
||||
def reset_db():
|
||||
"""
|
||||
Safe reset that works with Postgres (TRUNCATE ... CASCADE).
|
||||
Falls back to ordered deletes if TRUNCATE isn't supported (e.g., SQLite).
|
||||
"""
|
||||
try:
|
||||
# Postgres fast path
|
||||
db.session.execute(text("""
|
||||
TRUNCATE TABLE image_tags, archive_record, image_record, tag
|
||||
RESTART IDENTITY CASCADE
|
||||
"""))
|
||||
db.session.commit()
|
||||
except Exception:
|
||||
# Fallback: manual delete order
|
||||
db.session.execute(image_tags.delete())
|
||||
ArchiveRecord.query.delete()
|
||||
ImageRecord.query.delete()
|
||||
Tag.query.delete()
|
||||
db.session.commit()
|
||||
|
||||
# Optional: clear thumbs on disk to regenerate fresh
|
||||
shutil.rmtree("/images/thumbs", ignore_errors=True)
|
||||
os.makedirs("/images/thumbs", exist_ok=True)
|
||||
|
||||
flash("Database has been reset. All records removed.", "info")
|
||||
return redirect(url_for('main.settings'))
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# Tag add/remove endpoints
|
||||
# ----------------------------
|
||||
@@ -870,28 +821,6 @@ def save_import_settings():
|
||||
return jsonify(ok=False, error=str(e)), 500
|
||||
|
||||
|
||||
@main.get("/api/import-stats")
|
||||
def get_import_stats():
|
||||
"""Get import statistics including filtered image counts."""
|
||||
import json
|
||||
stats_path = "/import/stats.json"
|
||||
try:
|
||||
if os.path.exists(stats_path):
|
||||
with open(stats_path, "r") as f:
|
||||
stats = json.load(f)
|
||||
else:
|
||||
stats = {
|
||||
"total_processed": 0,
|
||||
"total_imported": 0,
|
||||
"filtered_by_dimension": 0,
|
||||
"filtered_by_transparency": 0,
|
||||
"filtered_by_duplicate": 0,
|
||||
}
|
||||
return jsonify(ok=True, stats=stats)
|
||||
except Exception as e:
|
||||
return jsonify(ok=False, error=str(e)), 500
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# Image filter/cleanup endpoints
|
||||
# ----------------------------
|
||||
|
||||
Reference in New Issue
Block a user