use hash for cached filenames

This commit is contained in:
Adam Velebil 2023-02-20 11:23:39 +01:00
parent 494e99b36f
commit 836fee3fe9
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
3 changed files with 5 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import 'dart:developer';
import 'dart:io';
import 'package:archive/archive.dart';
import 'package:crypto/crypto.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
@ -49,7 +50,8 @@ class FileSystemCache {
cacheDirectory = Directory('${documentsDirectory.path}${Platform.pathSeparator}issuer_icons_cache${Platform.pathSeparator}');
}
File _cachedFile(String fileName) => File('${cacheDirectory.path}${fileName}_cached');
File _cachedFile(String fileName) => File(
cacheDirectory.path + sha256.convert(utf8.encode(fileName)).toString());
Future<Uint8List?> getCachedFileData(String fileName) async {
final file = _cachedFile(fileName);

View File

@ -170,7 +170,7 @@ packages:
source: hosted
version: "0.3.3+4"
crypto:
dependency: transitive
dependency: "direct main"
description:
name: crypto
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67

View File

@ -59,6 +59,7 @@ dependencies:
path: ^1.8.2
file_picker: ^5.2.5
archive: ^3.3.2
crypto: ^3.0.2
dev_dependencies:
integration_test: