33 lines
864 B
Dart
33 lines
864 B
Dart
import 'dart:io';
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
import '../debug_log.dart';
|
|
|
|
//图片磁盘缓存目录(2025-07 ~ 2026-06 的版本经 loadAndDecrypt 往里存过原图,当前无写入方,保留统计和清理给老用户兜底)
|
|
class ImageDiskCache {
|
|
static Future<String> findSavePath() async {
|
|
final directory = await getTemporaryDirectory();
|
|
|
|
String saveDir = '${directory.path}/cacheImage';
|
|
Directory root = Directory(saveDir);
|
|
if (!root.existsSync()) {
|
|
debugLog(saveDir);
|
|
await root.create();
|
|
}
|
|
return saveDir;
|
|
}
|
|
|
|
static Future<void> emptyCache() async {
|
|
try {
|
|
String saveDir = await findSavePath();
|
|
Directory root = Directory(saveDir);
|
|
if (root.existsSync()) {
|
|
await root.delete(recursive: true);
|
|
}
|
|
} catch (e) {
|
|
debugLog(e);
|
|
}
|
|
}
|
|
}
|