From c6495251457791f463bd007a026ceac09f320e36 Mon Sep 17 00:00:00 2001 From: Moustapha Kodjo Amadou <107993382+kodjodevf@users.noreply.github.com> Date: Sat, 8 Nov 2025 21:54:15 +0100 Subject: [PATCH] Fix directory deletion logic to check existence before deletion --- lib/main.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 70d38f79..4f44eaf7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -133,10 +133,14 @@ Future _migrateOldLayout() async { } } // remove subfolder if empty - if (await oldSubDir.list().isEmpty) await oldSubDir.delete(); + if (await oldSubDir.exists() && await oldSubDir.list().isEmpty) { + await oldSubDir.delete(); + } } // Clean up old empty folder - if (await oldRoot.list().isEmpty) await oldRoot.delete(); + if (await oldRoot.exists() && await oldRoot.list().isEmpty) { + await oldRoot.delete(); + } } class MyApp extends ConsumerStatefulWidget {