Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add extra logging for sharing

laurenspriemb7f8a6cf6b51
diff --git a/mobile/apps/photos/lib/utils/share_util.dart b/mobile/apps/photos/lib/utils/share_util.dart
index f882c5a3cf..4b9ab1dd79 100644
--- a/mobile/apps/photos/lib/utils/share_util.dart
+++ b/mobile/apps/photos/lib/utils/share_util.dart
@@ -50,12 +50,26 @@ Future<void> share(
}
final paths = await Future.wait(pathFutures);
await dialog.hide();
- paths.removeWhere((element) => element == null);
- final xFiles = <XFile>[];
- for (String? path in paths) {
- if (path == null) continue;
- xFiles.add(XFile(path));
+ final resolvedPaths = <String>[];
+ for (var i = 0; i < paths.length; i++) {
+ final path = paths[i];
+ if (path == null) {
+ _logger.warning(
+ "share missing local path for file $i/${files.length} "
+ "(remote: ${files[i].isRemoteFile})",
+ );
+ continue;
+ }
+ resolvedPaths.add(path);
+ }
+ if (resolvedPaths.isEmpty) {
+ _logger.severe(
+ "share aborted: unable to resolve any files "
+ "(requested: ${files.length}, remote: $remoteFileCount)",
+ );
+ throw ArgumentError("No files resolved for system share");
}
+ final xFiles = resolvedPaths.map((path) => XFile(path)).toList();
await SharePlus.instance.share(
ShareParams(
files: xFiles,
@@ -64,7 +78,8 @@ Future<void> share(
);
} catch (e, s) {
_logger.severe(
- "failed to fetch files for system share ${files.length}",
+ "failed to complete system share ${files.length} "
+ "(remote: $remoteFileCount)",
e,
s,
);