From 3022a207ca42c9236917738c69f6e56eeeb68708 Mon Sep 17 00:00:00 2001 From: Jganenok Date: Wed, 10 Jun 2026 14:12:31 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BA=D0=B0=D0=BA=20=D0=B1=D1=8B=20?= =?UTF-8?q?=D0=BD=D0=B8=D1=85=D1=83=D1=8F=20=D0=BD=D0=B5=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=D0=BE=D1=81=D1=8C=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D1=81=D1=83=D1=82=D0=B8=20=D0=BD=D0=BE=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=81=D1=8F=D0=BA=D0=B8=D0=B9=20=D0=BF=D1=83=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20temp=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=BB=D0=BE=D0=B4=D1=8F=D1=82=D1=8C=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/attachment/media_preview_screen.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/frontend/widgets/attachment/media_preview_screen.dart b/lib/frontend/widgets/attachment/media_preview_screen.dart index d9c949a..423c062 100644 --- a/lib/frontend/widgets/attachment/media_preview_screen.dart +++ b/lib/frontend/widgets/attachment/media_preview_screen.dart @@ -102,6 +102,12 @@ class _MediaPreviewScreenState extends State { ); } + void _disposeTemp(File? file, Set keep) { + if (file == null || keep.contains(file.path)) return; + if (!file.uri.pathSegments.last.startsWith('komet_')) return; + file.delete().then((_) {}, onError: (_) {}); + } + Future _openCrop() async { if (_workingFile == null) return; final source = @@ -111,9 +117,11 @@ class _MediaPreviewScreenState extends State { PhotoCropEditor(source: source, initialState: _cropState), ); if (result != null && mounted) { + final old = _workingFile; _cropState = result.state; setState(() => _workingFile = result.file); _reportEdit(); + _disposeTemp(old, {result.file.path, _cropSource?.path ?? ''}); } } @@ -134,10 +142,14 @@ class _MediaPreviewScreenState extends State { ), ); if (result != null && mounted) { + final oldWorking = _workingFile; + final oldCropSource = _cropSource; _cropSource = result; _cropState = null; setState(() => _workingFile = result); _reportEdit(); + _disposeTemp(oldWorking, {result.path}); + _disposeTemp(oldCropSource, {result.path, oldWorking?.path ?? ''}); } } @@ -146,10 +158,14 @@ class _MediaPreviewScreenState extends State { if (file == null) return; final result = await _pushEditor(PhotoAdjustEditor(source: file)); if (result != null && mounted) { + final oldWorking = _workingFile; + final oldCropSource = _cropSource; _cropSource = result; _cropState = null; setState(() => _workingFile = result); _reportEdit(); + _disposeTemp(oldWorking, {result.path}); + _disposeTemp(oldCropSource, {result.path, oldWorking?.path ?? ''}); } }