Auto-commit local changes before build (2026-01-08 11:15:47)
This commit is contained in:
parent
30fa747fca
commit
1131f7f2fe
@ -1 +1 @@
|
|||||||
v20260108-26-changelog-0.1.18-update
|
v20260108-26-mail-move-only-after-successful-import
|
||||||
|
|||||||
@ -436,6 +436,21 @@ def run_auto_import(settings: SystemSettings):
|
|||||||
new_messages = 0
|
new_messages = 0
|
||||||
auto_approved = 0
|
auto_approved = 0
|
||||||
auto_approved_runs = []
|
auto_approved_runs = []
|
||||||
|
# Never move messages when the import failed (prevents "moved but not stored" situations).
|
||||||
|
processed_folder_id = None
|
||||||
|
|
||||||
|
# Ensure imported messages are committed before moving them to another folder.
|
||||||
|
# If commit fails, do not move anything.
|
||||||
|
if processed_folder_id and new_messages >= 0:
|
||||||
|
try:
|
||||||
|
db.session.commit()
|
||||||
|
except Exception as exc:
|
||||||
|
db.session.rollback()
|
||||||
|
errors.append(f"Failed to commit imported messages: {exc}")
|
||||||
|
new_messages = 0
|
||||||
|
auto_approved = 0
|
||||||
|
auto_approved_runs = []
|
||||||
|
processed_folder_id = None
|
||||||
|
|
||||||
# Move messages to the processed folder if configured
|
# Move messages to the processed folder if configured
|
||||||
if processed_folder_id:
|
if processed_folder_id:
|
||||||
@ -613,6 +628,21 @@ def run_manual_import(settings: SystemSettings, batch_size: int):
|
|||||||
errors.append(str(exc))
|
errors.append(str(exc))
|
||||||
new_messages = 0
|
new_messages = 0
|
||||||
auto_approved_runs = []
|
auto_approved_runs = []
|
||||||
|
# Never move messages when the import failed (prevents "moved but not stored" situations).
|
||||||
|
processed_folder_id = None
|
||||||
|
|
||||||
|
# Ensure imported messages are committed before moving them to another folder.
|
||||||
|
# If commit fails, do not move anything.
|
||||||
|
if processed_folder_id and new_messages >= 0:
|
||||||
|
try:
|
||||||
|
db.session.commit()
|
||||||
|
except Exception as exc:
|
||||||
|
db.session.rollback()
|
||||||
|
errors.append(f"Failed to commit imported messages: {exc}")
|
||||||
|
new_messages = 0
|
||||||
|
auto_approved = 0
|
||||||
|
auto_approved_runs = []
|
||||||
|
processed_folder_id = None
|
||||||
|
|
||||||
# Move messages to the processed folder if configured
|
# Move messages to the processed folder if configured
|
||||||
if processed_folder_id:
|
if processed_folder_id:
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
## v20260108-26-mail-move-only-after-successful-import
|
||||||
|
|
||||||
|
- Changed mail import flow so messages are only moved to the processed folder after a successful database store and commit.
|
||||||
|
- Prevented Graph mails from being moved when parsing, storing, or committing to the database fails.
|
||||||
|
- Added explicit commit and rollback handling to ensure database integrity before mail state changes.
|
||||||
|
- Improved logging around import and commit failures to better trace skipped or retried mails.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user