Skip to content

bug(export): delete partial file when saveToFile streaming fails #465

Description

@ZhuchkaTriplesix

Parent

Part of #463

Severity

Medium

Problem

DataExportService.saveToFile opens the destination with openWrite and streams via writeToSink. On failure it closes the sink and returns SaveExportOutcome.error, but never deletes the partially written file. User can get a truncated CSV/JSON/SQL on disk while UI only shows a generic export error.

Evidence

  • lib/shared/services/data_export_service.dart (~343–360)
  • Bugbot review dev vs main (2026-07-27)

Acceptance

  • On stream/write failure, partial destination file is removed (best-effort)
  • Successful save unchanged
  • Test covering failure path cleans up the file

Suggested fix

try/finally or catch: if outcome is error and file exists, await file.delete() (ignore delete errors).

Metadata

Metadata

Labels

bugSomething isn't workingcoreCore library logic and servicesuiUser interface components and widgets

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions