diff --git a/lib/models/location/location.dart b/lib/models/location/location.dart index 35ace437985fc90bc6e6ca187d809f143b1a8ece..2ef539e5fa69c42f45591e1a3319b1d7a023b58c 100644 --- a/lib/models/location/location.dart +++ b/lib/models/location/location.dart @@ -12,4 +12,18 @@ class Location with _$Location { factory Location.fromJson(Map json) => _$LocationFromJson(json); + + static isValidLocation(Location? location) { + if (location == null) return false; + if (location.latitude == null || location.longitude == null) return false; + final latValue = location.latitude!; + final longValue = location.longitude!; + if (latValue.isNaN || latValue.isNaN || latValue == 0.0) { + return false; + } + if (longValue.isInfinite || longValue.isInfinite || longValue == 0.0) { + return false; + } + return true; + } } diff --git a/lib/services/local_file_update_service.dart b/lib/services/local_file_update_service.dart index 7cdec9c4a738e7dc588cc61dc8067ce50d8046f1..663fec1607d7597ff6f39655f407c86792886472 100644 --- a/lib/services/local_file_update_service.dart +++ b/lib/services/local_file_update_service.dart @@ -257,9 +257,7 @@ class LocalFileUpdateService { for (ente.File file in enteFiles) { final Location? location = await tryLocationFromExif(file); - if (location != null && - (location.latitude ?? 0) != 0.0 && - (location.longitude ?? 0) != 0.0) { + if (location != null && Location.isValidLocation(location)) { remoteFilesToUpdate.add(file); fileIDToUpdateMetadata[file.uploadedFileID!] = { pubMagicKeyLat: location.latitude!,