[mob] Fix: Enable video upload without thumbnail for shared files (#3506)

## Description

## Tests
This commit is contained in:
Neeraj Gupta
2024-09-28 14:22:35 +05:30
committed by GitHub
3 changed files with 17 additions and 11 deletions

View File

@@ -133,7 +133,7 @@ class MLService {
}
if (_mlControllerStatus == true) {
// refresh discover section
MagicCacheService.instance.updateCache().ignore();
MagicCacheService.instance.updateCache(forced: force).ignore();
}
await indexAllImages();
if ((await MLDataDB.instance.getUnclusteredFaceCount()) > 0) {

View File

@@ -205,7 +205,7 @@ class MagicCacheService {
queueUpdate("Prompts data updated");
} else if (lastMagicCacheUpdateTime <
DateTime.now()
.subtract(const Duration(days: 1))
.subtract(const Duration(hours: 12))
.millisecondsSinceEpoch) {
queueUpdate("Cache is old");
}

View File

@@ -342,7 +342,8 @@ Future<MediaUploadData> _getMediaUploadDataFromAppCache(EnteFile file) async {
Map<String, int>? dimensions;
if (file.fileType == FileType.image) {
dimensions = await getImageHeightAndWith(imagePath: localPath);
} else {
} else if (thumbnailData != null) {
// the thumbnail null check is to ensure that we are able to generate thum
// for video, we need to use the thumbnail data with any max width/height
final thumbnailFilePath = await VideoThumbnail.thumbnailFile(
video: localPath,
@@ -406,14 +407,19 @@ Future<Uint8List?> getThumbnailFromInAppCacheFile(EnteFile file) async {
return null;
}
if (file.fileType == FileType.video) {
final thumbnailFilePath = await VideoThumbnail.thumbnailFile(
video: localFile.path,
imageFormat: ImageFormat.JPEG,
thumbnailPath: (await getTemporaryDirectory()).path,
maxWidth: thumbnailLargeSize,
quality: 80,
);
localFile = File(thumbnailFilePath!);
try {
final thumbnailFilePath = await VideoThumbnail.thumbnailFile(
video: localFile.path,
imageFormat: ImageFormat.JPEG,
thumbnailPath: (await getTemporaryDirectory()).path,
maxWidth: thumbnailLargeSize,
quality: 80,
);
localFile = File(thumbnailFilePath!);
} catch (e) {
_logger.warning('Failed to generate video thumbnail', e);
return null;
}
}
var thumbnailData = await localFile.readAsBytes();
int compressionAttempts = 0;