Skip to content

Commit 3ee0cc6

Browse files
committed
Refactor asset hash reading in extractAssetOrFile
Moved asset hash reading outside of the checkHash block to ensure it is always attempted. Removed redundant debug prints and simplified hash file writing logic.
1 parent 9b6f2c1 commit 3ee0cc6

File tree

1 file changed

+6
-11
lines changed
  • src/serious_python_platform_interface/lib/src

1 file changed

+6
-11
lines changed

src/serious_python_platform_interface/lib/src/utils.dart

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Future<String> extractAssetOrFile(String path,
1515
Directory(p.join(supportDir.path, "flet", targetPath ?? p.dirname(path)));
1616

1717
String assetHash = "";
18+
// read asset hash from asset
19+
try {
20+
assetHash = (await rootBundle.loadString("$path.hash")).trim();
21+
// ignore: empty_catches
22+
} catch (e) {}
23+
1824
String destHash = "";
1925
var hashFile = File(p.join(destDir.path, ".hash"));
2026

@@ -25,14 +31,6 @@ Future<String> extractAssetOrFile(String path,
2531
await destDir.delete(recursive: true);
2632
} else {
2733
if (checkHash) {
28-
// read asset hash from asset
29-
try {
30-
assetHash = (await rootBundle.loadString("$path.hash")).trim();
31-
debugPrint("Asset hash for $path: $assetHash");
32-
// ignore: empty_catches
33-
} catch (e) {
34-
debugPrint("No asset hash file found for $path.hash: $e");
35-
}
3634
if (await hashFile.exists()) {
3735
destHash = (await hashFile.readAsString()).trim();
3836
}
@@ -77,9 +75,6 @@ Future<String> extractAssetOrFile(String path,
7775
if (checkHash) {
7876
debugPrint("Writing hash file: ${hashFile.path}, hash: $assetHash");
7977
await hashFile.writeAsString(assetHash);
80-
debugPrint("Hash file written.");
81-
} else {
82-
debugPrint("Hash check not requested, skipping hash file write.");
8378
}
8479

8580
return destDir.path;

0 commit comments

Comments
 (0)