From 14169d310a3598a44fcfbd251cee97811c78138e Mon Sep 17 00:00:00 2001
From: Alex <alex.tran1502@gmail.com>
Date: Sat, 21 Sep 2024 07:29:07 +0700
Subject: [PATCH] fix(mobile): fix uncaught error in getting file cause hashing
 procses to be aborted entirely (#12826)

* fix(mobile): fix uncaught error in getting file cause hashing procses to be aborted entirely

* log error
---
 mobile/lib/services/hash.service.dart | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/mobile/lib/services/hash.service.dart b/mobile/lib/services/hash.service.dart
index 2ec545453f..94d680972f 100644
--- a/mobile/lib/services/hash.service.dart
+++ b/mobile/lib/services/hash.service.dart
@@ -65,7 +65,19 @@ class HashService {
       if (hashes[i] != null) {
         continue;
       }
-      final file = await assets[i].local!.originFile;
+
+      File? file;
+
+      try {
+        file = await assets[i].local!.originFile;
+      } catch (error, stackTrace) {
+        _log.warning(
+          "Error getting file to hash for asset ${assets[i].localId}, name: ${assets[i].fileName}, created on: ${assets[i].fileCreatedAt}, skipping",
+          error,
+          stackTrace,
+        );
+      }
+
       if (file == null) {
         final fileName = assets[i].fileName;