From d4eb95d47788b94790c1b41b885ce639180a11e4 Mon Sep 17 00:00:00 2001 From: orz12 Date: Tue, 23 Jul 2024 12:00:50 +0800 Subject: [PATCH] mod: fix iOS delete NSCachesDirectory no permission --- lib/pages/setting/extra_setting.dart | 2 +- lib/utils/cache_manage.dart | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 693d18ec8..78fb27d93 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -300,7 +300,7 @@ class _ExtraSettingState extends State { ), const SetSwitchItem( title: '自动清除缓存', - subTitle: '每次启动时清除缓存(iOS不支持)', + subTitle: '每次启动时清除缓存', leading: Icon(Icons.auto_delete_outlined), setKey: SettingBoxKey.autoClearCache, defaultVal: false, diff --git a/lib/utils/cache_manage.dart b/lib/utils/cache_manage.dart index daa58bc2a..eed2e7af4 100644 --- a/lib/utils/cache_manage.dart +++ b/lib/utils/cache_manage.dart @@ -137,7 +137,12 @@ class CacheManage { static Future clearLibraryCache() async { var appDocDir = await getTemporaryDirectory(); if (appDocDir.existsSync()) { - await appDocDir.delete(recursive: true); + // await appDocDir.delete(recursive: true); + final List children = + appDocDir.listSync(recursive: false); + for (final FileSystemEntity file in children) { + await file.delete(recursive: true); + } } }