ML file download logs (#2979)

## Description

More logging regarding download/obtaining file for ML indexing
This commit is contained in:
Laurens Priem
2024-08-27 10:33:29 +02:00
committed by GitHub
3 changed files with 8 additions and 4 deletions

View File

@@ -495,7 +495,7 @@ class MLService {
return true;
}
_logger.severe(
"Failed to analyze using FaceML for image with ID: ${instruction.file.uploadedFileID}. Not storing any results locally, which means it will be automatically retried later.",
"Failed to analyze using FaceML for image with ID: ${instruction.file.uploadedFileID} and format ${instruction.file.displayName.split('.').last} (${instruction.file.fileType}). Not storing any results locally, which means it will be automatically retried later.",
e,
s,
);

View File

@@ -299,7 +299,8 @@ Future<String> getImagePathForML(EnteFile enteFile) async {
final stopwatch = Stopwatch()..start();
File? file;
if (enteFile.fileType == FileType.video) {
final bool isVideo = enteFile.fileType == FileType.video;
if (isVideo) {
try {
file = await getThumbnailForUploadedFile(enteFile);
} on PlatformException catch (e, s) {
@@ -328,8 +329,8 @@ Future<String> getImagePathForML(EnteFile enteFile) async {
);
if (imagePath == null) {
_logger.warning(
"Failed to get any data for enteFile with uploadedFileID ${enteFile.uploadedFileID} since its file path is null",
_logger.severe(
"Failed to get any data for enteFile with uploadedFileID ${enteFile.uploadedFileID} and format ${enteFile.displayName.split('.').last} and size ${enteFile.fileSize} since its file path is null (isVideo: $isVideo)",
);
throw CouldNotRetrieveAnyFileData();
}

View File

@@ -47,6 +47,7 @@ Future<Uint8List?> getThumbnail(EnteFile file) async {
Future<File?> getThumbnailForUploadedFile(EnteFile file) async {
final cachedThumbnail = cachedThumbnailPath(file);
if (await cachedThumbnail.exists()) {
_logger.info("Thumbnail already exists for ${file.uploadedFileID}");
return cachedThumbnail;
}
final thumbnail = await getThumbnail(file);
@@ -55,8 +56,10 @@ Future<File?> getThumbnailForUploadedFile(EnteFile file) async {
if (!await cachedThumbnail.exists()) {
await cachedThumbnail.writeAsBytes(thumbnail, flush: true);
}
_logger.info("Thumbnail obtained for ${file.uploadedFileID}");
return cachedThumbnail;
}
_logger.severe("Failed to get thumbnail for ${file.uploadedFileID}");
return null;
}