Minor bug fixes (#1053)

This commit is contained in:
Neeraj Gupta 2023-05-02 19:18:53 +05:30 committed by GitHub
commit 1917b257cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 7 deletions

View file

@ -878,6 +878,7 @@ class MessageLookup extends MessageLookupByLibrary {
"publicLinkEnabled":
MessageLookupByLibrary.simpleMessage("Publieke link ingeschakeld"),
"radius": MessageLookupByLibrary.simpleMessage("Straal"),
"raiseTicket": MessageLookupByLibrary.simpleMessage("Meld probleem"),
"rateTheApp": MessageLookupByLibrary.simpleMessage("Beoordeel de app"),
"rateUs": MessageLookupByLibrary.simpleMessage("Beoordeel ons"),
"rateUsOnStore": m18,

View file

@ -12,4 +12,18 @@ class Location with _$Location {
factory Location.fromJson(Map<String, Object?> 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.isInfinite || latValue == 0.0) {
return false;
}
if (longValue.isNaN || longValue.isInfinite || longValue == 0.0) {
return false;
}
return true;
}
}

View file

@ -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!,

View file

@ -305,8 +305,11 @@ class CryptoUtil {
args["sourceFilePath"] = sourceFilePath;
args["destinationFilePath"] = destinationFilePath;
args["key"] = key;
return _computer.compute(chachaEncryptFile,
param: args, taskName: "encryptFile");
return _computer.compute(
chachaEncryptFile,
param: args,
taskName: "encryptFile",
);
}
// Decrypts the file at sourceFilePath, with the given key and header using

View file

@ -388,14 +388,15 @@ class FileUploader {
await io.File(encryptedFilePath).delete();
}
final encryptedFile = io.File(encryptedFilePath);
final fileAttributes = await CryptoUtil.encryptFile(
final EncryptionResult fileAttributes = await CryptoUtil.encryptFile(
mediaUploadData!.sourceFile!.path,
encryptedFilePath,
key: key,
);
final thumbnailData = mediaUploadData.thumbnail;
final encryptedThumbnailData = await CryptoUtil.encryptChaCha(
final EncryptionResult encryptedThumbnailData =
await CryptoUtil.encryptChaCha(
thumbnailData!,
fileAttributes.key!,
);
@ -480,6 +481,7 @@ class FileUploader {
await encryptedThumbnailFile.length(),
encryptedMetadata,
metadataDecryptionHeader,
pubMetadata: pubMetadataRequest,
);
if (mediaUploadData.isDeleted) {
_logger.info("File found to be deleted");