Merge pull request #3 from Pacalini/cache

cache manager: fix setLimitSize & checkCache
This commit is contained in:
nyne
2024-10-29 12:17:22 +08:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -135,7 +135,7 @@ class CacheManager {
WHERE expires < ?
''', [DateTime.now().millisecondsSinceEpoch]);
for(var row in res){
var dir = row[1] as int;
var dir = row[1] as String;
var name = row[2] as String;
var file = File('$cachePath/$dir/$name');
if(await file.exists()){
@@ -158,12 +158,12 @@ class CacheManager {
while((_currentSize != null && _currentSize! > _limitSize) || count > 2000){
var res = _db.select('''
SELECT * FROM cache
ORDER BY time ASC
ORDER BY expires ASC
limit 10
''');
for(var row in res){
var key = row[0] as String;
var dir = row[1] as int;
var dir = row[1] as String;
var name = row[2] as String;
var file = File('$cachePath/$dir/$name');
if(await file.exists()){

View File

@@ -79,7 +79,7 @@ class _AppSettingsState extends State<AppSettings> {
appdata.saveData();
setState(() {});
CacheManager()
.setLimitSize(appdata.settings['cacheSize'] * 1024 * 1024);
.setLimitSize(appdata.settings['cacheSize']);
return null;
},
);