Merge branch 'master' into mobile-search

This commit is contained in:
ashilkn 2022-07-21 16:22:11 +05:30
commit 537db7b0b4
5 changed files with 34 additions and 11 deletions

View file

@ -2,38 +2,38 @@ import 'dart:typed_data';
import 'package:photos/core/cache/lru_map.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/models/file.dart';
import 'package:photos/models/ente_file.dart';
class ThumbnailLruCache {
static final LRUMap<String, Uint8List> _map = LRUMap(1000);
static Uint8List get(File photo, [int size]) {
static Uint8List get(EnteFile enteFile, [int size]) {
return _map.get(
photo.generatedID.toString() +
enteFile.cacheKey() +
"_" +
(size != null ? size.toString() : kThumbnailLargeSize.toString()),
);
}
static void put(
File photo,
EnteFile enteFile,
Uint8List imageData, [
int size,
]) {
_map.put(
photo.generatedID.toString() +
enteFile.cacheKey() +
"_" +
(size != null ? size.toString() : kThumbnailLargeSize.toString()),
imageData,
);
}
static void clearCache(File file) {
static void clearCache(EnteFile enteFile) {
_map.remove(
file.generatedID.toString() + "_" + kThumbnailLargeSize.toString(),
enteFile.cacheKey() + "_" + kThumbnailLargeSize.toString(),
);
_map.remove(
file.generatedID.toString() + "_" + kThumbnailSmallSize.toString(),
enteFile.cacheKey() + "_" + kThumbnailSmallSize.toString(),
);
}
}

11
lib/models/ente_file.dart Normal file
View file

@ -0,0 +1,11 @@
// EnteFile is base file entry for various type of files
// like DeviceFile,RemoteFile or TrashedFile
abstract class EnteFile {
// returns cacheKey which should be used while caching entry related to
// this file.
String cacheKey();
// returns localIdentifier for the file on the host OS.
// Can be null if the file only exist on remote
String localIdentifier();
}

View file

@ -6,6 +6,7 @@ import 'package:path/path.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/models/ente_file.dart';
import 'package:photos/models/file_type.dart';
import 'package:photos/models/location.dart';
import 'package:photos/models/magic_metadata.dart';
@ -13,7 +14,7 @@ import 'package:photos/services/feature_flag_service.dart';
import 'package:photos/utils/crypto_util.dart';
import 'package:photos/utils/exif_util.dart';
class File {
class File extends EnteFile {
int generatedID;
int uploadedFileID;
int ownerID;
@ -262,4 +263,15 @@ class File {
":generated_" +
generatedID.toString();
}
@override
String cacheKey() {
// todo: Neeraj: 19thJuly'22: evaluate and add fileHash as the key?
return localID ?? uploadedFileID?.toString() ?? generatedID?.toString();
}
@override
String localIdentifier() {
return localID;
}
}

View file

@ -91,7 +91,7 @@ Future<List<File>> convertIncomingSharedMediaToFile(
enteFile.creationTime = exifTime.microsecondsSinceEpoch;
}
} else if (enteFile.fileType == FileType.video) {
enteFile.duration = media.duration ?? 0;
enteFile.duration = media.duration ~/ 1000 ?? 0;
}
if (enteFile.creationTime == null || enteFile.creationTime == 0) {
final parsedDateTime =

View file

@ -11,7 +11,7 @@ description: ente photos application
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.6.17+347
version: 0.6.19+349
environment:
sdk: ">=2.10.0 <3.0.0"