Clear Cache: Delete content from iOS /tmp directory

This commit is contained in:
Neeraj Gupta 2023-01-04 12:46:20 +05:30
parent 15566f4078
commit 7c45201380
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -25,6 +25,7 @@ class AppStorageViewer extends StatefulWidget {
class _AppStorageViewerState extends State<AppStorageViewer> {
final List<PathStorageItem> paths = [];
late String iosTempDirectoryPath;
late bool internalUser;
int _refreshCounterKey = 0;
@ -39,9 +40,9 @@ class _AppStorageViewerState extends State<AppStorageViewer> {
final appDocumentsDirectory = (await getApplicationDocumentsDirectory());
final appSupportDirectory = (await getApplicationSupportDirectory());
final appTemporaryDirectory = (await getTemporaryDirectory());
final iOSOnlyTempDirectory = "${appDocumentsDirectory.parent.path}/tmp/";
iosTempDirectoryPath = "${appDocumentsDirectory.parent.path}/tmp/";
final iOSPhotoManagerInAppCacheDirectory =
iOSOnlyTempDirectory + "flutter-images";
iosTempDirectoryPath + "flutter-images";
final androidGlideCacheDirectory =
"${appTemporaryDirectory.path}/image_manager_disk_cache/";
@ -84,7 +85,7 @@ class _AppStorageViewerState extends State<AppStorageViewer> {
PathStorageItem.name(appTemporaryDirectory.path, "App Temp Dir"),
]);
if (!Platform.isAndroid) {
paths.add(PathStorageItem.name(iOSOnlyTempDirectory, "/tmp directory"));
paths.add(PathStorageItem.name(iosTempDirectoryPath, "/tmp directory"));
}
}
if (mounted) {
@ -171,6 +172,11 @@ class _AppStorageViewerState extends State<AppStorageViewer> {
);
}
}
if (!Platform.isAndroid) {
await deleteDirectoryContents(
iosTempDirectoryPath,
);
}
_refreshCounterKey++;
if (mounted) {
setState(() => {});