Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 1505(Fix cache delete) #1507

Merged
merged 5 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 8.1.2
### Android
- Fixes a cache deletion issue [#1505](https://github.com/miguelpruivo/flutter_file_picker/issues/1505)

## 8.1.1
### Web
- Migrate the web example to use the new web bootstrapping, introduced in Flutter 3.22.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,7 @@ public static HashMap<String, Object> createFileInfoMap(File compressedImageFile
public static boolean clearCache(final Context context) {
try {
final File cacheDir = new File(context.getCacheDir() + "/file_picker/");
final File[] files = cacheDir.listFiles();

if (files != null) {
for (final File file : files) {
file.delete();
}
}
recursiveDeleteFile(cacheDir);
} catch (final Exception ex) {
Log.e(TAG, "There was an error while clearing cached files: " + ex.toString());
return false;
Expand Down Expand Up @@ -471,4 +465,18 @@ private static String getDocumentPathFromTreeUri(final Uri treeUri) {
else return File.separator;
}

private static void recursiveDeleteFile(final File file) throws Exception {
if (file == null || !file.exists()) {
return;
}

if (file.isDirectory()) {
for (File child : file.listFiles()) {
recursiveDeleteFile(child);
}
}

file.delete();
}

}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A package that allows you to use a native file explorer to pick sin
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
repository: https://github.com/miguelpruivo/flutter_file_picker
issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues
version: 8.1.1
version: 8.1.2

dependencies:
flutter:
Expand Down
Loading