Speed up memories (#1661)
This commit is contained in:
commit
fe5cba5b74
19 changed files with 98 additions and 16 deletions
|
@ -181,6 +181,21 @@ PODS:
|
|||
- sqflite (0.0.3):
|
||||
- Flutter
|
||||
- FMDB (>= 2.7.5)
|
||||
- sqlite3 (3.45.0):
|
||||
- sqlite3/common (= 3.45.0)
|
||||
- sqlite3/common (3.45.0)
|
||||
- sqlite3/fts5 (3.45.0):
|
||||
- sqlite3/common
|
||||
- sqlite3/perf-threadsafe (3.45.0):
|
||||
- sqlite3/common
|
||||
- sqlite3/rtree (3.45.0):
|
||||
- sqlite3/common
|
||||
- sqlite3_flutter_libs (0.0.1):
|
||||
- Flutter
|
||||
- sqlite3 (~> 3.45.0)
|
||||
- sqlite3/fts5
|
||||
- sqlite3/perf-threadsafe
|
||||
- sqlite3/rtree
|
||||
- Toast (4.0.0)
|
||||
- uni_links (0.0.1):
|
||||
- Flutter
|
||||
|
@ -235,6 +250,7 @@ DEPENDENCIES:
|
|||
- share_plus (from `.symlinks/plugins/share_plus/ios`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
||||
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
|
||||
- uni_links (from `.symlinks/plugins/uni_links/ios`)
|
||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`)
|
||||
|
@ -264,6 +280,7 @@ SPEC REPOS:
|
|||
- SDWebImageWebPCoder
|
||||
- Sentry
|
||||
- SentryPrivate
|
||||
- sqlite3
|
||||
- Toast
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
|
@ -343,6 +360,8 @@ EXTERNAL SOURCES:
|
|||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||
sqflite:
|
||||
:path: ".symlinks/plugins/sqflite/ios"
|
||||
sqlite3_flutter_libs:
|
||||
:path: ".symlinks/plugins/sqlite3_flutter_libs/ios"
|
||||
uni_links:
|
||||
:path: ".symlinks/plugins/uni_links/ios"
|
||||
url_launcher_ios:
|
||||
|
@ -415,6 +434,8 @@ SPEC CHECKSUMS:
|
|||
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
|
||||
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
|
||||
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
|
||||
sqlite3: f307b6291c4db7b5086c38d6237446b98a738581
|
||||
sqlite3_flutter_libs: aeb4d37509853dfa79d9b59386a2dac5dd079428
|
||||
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
|
||||
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
|
||||
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
|
||||
|
|
|
@ -311,6 +311,8 @@
|
|||
"${BUILT_PRODUCTS_DIR}/share_plus/share_plus.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/shared_preferences_foundation/shared_preferences_foundation.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/sqlite3/sqlite3.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/uni_links/uni_links.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework",
|
||||
|
@ -390,6 +392,8 @@
|
|||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share_plus.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_foundation.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/uni_links.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework",
|
||||
|
|
|
@ -15,6 +15,7 @@ import "package:photos/services/filter/db_filters.dart";
|
|||
import 'package:photos/utils/file_uploader_util.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:sqflite_migration/sqflite_migration.dart';
|
||||
import 'package:sqlite3/sqlite3.dart' as sqlite3;
|
||||
|
||||
class FilesDB {
|
||||
/*
|
||||
|
@ -100,6 +101,7 @@ class FilesDB {
|
|||
|
||||
// only have a single app-wide reference to the database
|
||||
static Future<Database>? _dbFuture;
|
||||
static Future<sqlite3.Database>? _ffiDBFuture;
|
||||
|
||||
Future<Database> get database async {
|
||||
// lazily instantiate the db the first time it is accessed
|
||||
|
@ -107,6 +109,11 @@ class FilesDB {
|
|||
return _dbFuture!;
|
||||
}
|
||||
|
||||
Future<sqlite3.Database> get ffiDB async {
|
||||
_ffiDBFuture ??= _initFFIDatabase();
|
||||
return _ffiDBFuture!;
|
||||
}
|
||||
|
||||
// this opens the database (and creates it if it doesn't exist)
|
||||
Future<Database> _initDatabase() async {
|
||||
final Directory documentsDirectory =
|
||||
|
@ -116,6 +123,14 @@ class FilesDB {
|
|||
return await openDatabaseWithMigration(path, dbConfig);
|
||||
}
|
||||
|
||||
Future<sqlite3.Database> _initFFIDatabase() async {
|
||||
final Directory documentsDirectory =
|
||||
await getApplicationDocumentsDirectory();
|
||||
final String path = join(documentsDirectory.path, _databaseName);
|
||||
_logger.info("DB path " + path);
|
||||
return sqlite3.sqlite3.open(path);
|
||||
}
|
||||
|
||||
// SQL code to create the database table
|
||||
static List<String> createTable(String tableName) {
|
||||
return [
|
||||
|
@ -749,6 +764,40 @@ class FilesDB {
|
|||
);
|
||||
}
|
||||
|
||||
Future<List<EnteFile>> getFilesCreatedWithinDurationsSync(
|
||||
List<List<int>> durations,
|
||||
Set<int> ignoredCollectionIDs, {
|
||||
int? visibility,
|
||||
String order = 'ASC',
|
||||
}) async {
|
||||
if (durations.isEmpty) {
|
||||
return <EnteFile>[];
|
||||
}
|
||||
final db = await instance.ffiDB;
|
||||
String whereClause = "( ";
|
||||
for (int index = 0; index < durations.length; index++) {
|
||||
whereClause += "($columnCreationTime >= " +
|
||||
durations[index][0].toString() +
|
||||
" AND $columnCreationTime < " +
|
||||
durations[index][1].toString() +
|
||||
")";
|
||||
if (index != durations.length - 1) {
|
||||
whereClause += " OR ";
|
||||
} else if (visibility != null) {
|
||||
whereClause += ' AND $columnMMdVisibility = $visibility';
|
||||
}
|
||||
}
|
||||
whereClause += ")";
|
||||
final results = db.select(
|
||||
'select * from $filesTable where $whereClause order by $columnCreationTime $order',
|
||||
);
|
||||
final files = convertToFiles(results);
|
||||
return applyDBFilters(
|
||||
files,
|
||||
DBFilterOptions(ignoredCollectionIDs: ignoredCollectionIDs),
|
||||
);
|
||||
}
|
||||
|
||||
// Files which user added to a collection manually but they are not
|
||||
// uploaded yet or files belonging to a collection which is marked for backup
|
||||
Future<List<EnteFile>> getFilesPendingForUpload() async {
|
||||
|
|
1
lib/generated/intl/messages_cs.dart
generated
1
lib/generated/intl/messages_cs.dart
generated
|
@ -34,7 +34,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage(
|
||||
"Edits to location will only be seen within Ente"),
|
||||
"fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"modifyYourQueryOrTrySearchingFor":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
"Modify your query, or try searching for"),
|
||||
|
|
1
lib/generated/intl/messages_de.dart
generated
1
lib/generated/intl/messages_de.dart
generated
|
@ -898,7 +898,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"maps": MessageLookupByLibrary.simpleMessage("Karten"),
|
||||
"mastodon": MessageLookupByLibrary.simpleMessage("Mastodon"),
|
||||
"matrix": MessageLookupByLibrary.simpleMessage("Matrix"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"memoryCount": m31,
|
||||
"merchandise": MessageLookupByLibrary.simpleMessage("Merchandise"),
|
||||
"mobileWebDesktop":
|
||||
|
|
1
lib/generated/intl/messages_en.dart
generated
1
lib/generated/intl/messages_en.dart
generated
|
@ -871,7 +871,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"maps": MessageLookupByLibrary.simpleMessage("Maps"),
|
||||
"mastodon": MessageLookupByLibrary.simpleMessage("Mastodon"),
|
||||
"matrix": MessageLookupByLibrary.simpleMessage("Matrix"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"memoryCount": m31,
|
||||
"merchandise": MessageLookupByLibrary.simpleMessage("Merchandise"),
|
||||
"mobileWebDesktop":
|
||||
|
|
1
lib/generated/intl/messages_es.dart
generated
1
lib/generated/intl/messages_es.dart
generated
|
@ -790,7 +790,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage("Administrar tu suscripción"),
|
||||
"mastodon": MessageLookupByLibrary.simpleMessage("Mastodon"),
|
||||
"matrix": MessageLookupByLibrary.simpleMessage("Matrix"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"memoryCount": m31,
|
||||
"merchandise": MessageLookupByLibrary.simpleMessage("Mercancías"),
|
||||
"mobileWebDesktop":
|
||||
|
|
1
lib/generated/intl/messages_fr.dart
generated
1
lib/generated/intl/messages_fr.dart
generated
|
@ -898,7 +898,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"maps": MessageLookupByLibrary.simpleMessage("Cartes"),
|
||||
"mastodon": MessageLookupByLibrary.simpleMessage("Mastodon"),
|
||||
"matrix": MessageLookupByLibrary.simpleMessage("Matrix"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"memoryCount": m31,
|
||||
"merchandise": MessageLookupByLibrary.simpleMessage("Marchandise"),
|
||||
"mobileWebDesktop":
|
||||
|
|
1
lib/generated/intl/messages_it.dart
generated
1
lib/generated/intl/messages_it.dart
generated
|
@ -867,7 +867,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"maps": MessageLookupByLibrary.simpleMessage("Mappe"),
|
||||
"mastodon": MessageLookupByLibrary.simpleMessage("Mastodon"),
|
||||
"matrix": MessageLookupByLibrary.simpleMessage("Matrix"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"memoryCount": m31,
|
||||
"merchandise": MessageLookupByLibrary.simpleMessage("Merchandise"),
|
||||
"mobileWebDesktop":
|
||||
|
|
1
lib/generated/intl/messages_ko.dart
generated
1
lib/generated/intl/messages_ko.dart
generated
|
@ -34,7 +34,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage(
|
||||
"Edits to location will only be seen within Ente"),
|
||||
"fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"modifyYourQueryOrTrySearchingFor":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
"Modify your query, or try searching for"),
|
||||
|
|
1
lib/generated/intl/messages_nl.dart
generated
1
lib/generated/intl/messages_nl.dart
generated
|
@ -889,7 +889,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"maps": MessageLookupByLibrary.simpleMessage("Kaarten"),
|
||||
"mastodon": MessageLookupByLibrary.simpleMessage("Mastodon"),
|
||||
"matrix": MessageLookupByLibrary.simpleMessage("Matrix"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"memoryCount": m31,
|
||||
"merchandise": MessageLookupByLibrary.simpleMessage("Merchandise"),
|
||||
"mobileWebDesktop":
|
||||
|
|
1
lib/generated/intl/messages_no.dart
generated
1
lib/generated/intl/messages_no.dart
generated
|
@ -56,7 +56,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
MessageLookupByLibrary.simpleMessage("Ugyldig e-postadresse"),
|
||||
"kindlyHelpUsWithThisInformation": MessageLookupByLibrary.simpleMessage(
|
||||
"Vær vennlig og hjelp oss med denne informasjonen"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"modifyYourQueryOrTrySearchingFor":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
"Modify your query, or try searching for"),
|
||||
|
|
1
lib/generated/intl/messages_pl.dart
generated
1
lib/generated/intl/messages_pl.dart
generated
|
@ -116,7 +116,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"kindlyHelpUsWithThisInformation":
|
||||
MessageLookupByLibrary.simpleMessage("Pomóż nam z tą informacją"),
|
||||
"logInLabel": MessageLookupByLibrary.simpleMessage("Zaloguj się"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"moderateStrength": MessageLookupByLibrary.simpleMessage("Umiarkowana"),
|
||||
"modifyYourQueryOrTrySearchingFor":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
|
|
1
lib/generated/intl/messages_pt.dart
generated
1
lib/generated/intl/messages_pt.dart
generated
|
@ -266,7 +266,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"lostDevice":
|
||||
MessageLookupByLibrary.simpleMessage("Dispositivo perdido?"),
|
||||
"manage": MessageLookupByLibrary.simpleMessage("Gerenciar"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"moderateStrength": MessageLookupByLibrary.simpleMessage("Moderada"),
|
||||
"modifyYourQueryOrTrySearchingFor":
|
||||
MessageLookupByLibrary.simpleMessage(
|
||||
|
|
2
lib/generated/intl/messages_zh.dart
generated
2
lib/generated/intl/messages_zh.dart
generated
|
@ -738,7 +738,6 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"maps": MessageLookupByLibrary.simpleMessage("地图"),
|
||||
"mastodon": MessageLookupByLibrary.simpleMessage("Mastodon"),
|
||||
"matrix": MessageLookupByLibrary.simpleMessage("Matrix"),
|
||||
"memories": MessageLookupByLibrary.simpleMessage("Memories"),
|
||||
"memoryCount": m31,
|
||||
"merchandise": MessageLookupByLibrary.simpleMessage("商品"),
|
||||
"mobileWebDesktop":
|
||||
|
@ -1217,6 +1216,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"viewer": MessageLookupByLibrary.simpleMessage("查看者"),
|
||||
"visitWebToManage":
|
||||
MessageLookupByLibrary.simpleMessage("请访问 web.ente.io 来管理您的订阅"),
|
||||
"waitingForWifi": MessageLookupByLibrary.simpleMessage("正在等待 WiFi..."),
|
||||
"weAreOpenSource": MessageLookupByLibrary.simpleMessage("我们是开源的 !"),
|
||||
"weDontSupportEditingPhotosAndAlbumsThatYouDont":
|
||||
MessageLookupByLibrary.simpleMessage("我们不支持编辑您尚未拥有的照片和相册"),
|
||||
|
|
|
@ -107,7 +107,7 @@ class MemoriesService extends ChangeNotifier {
|
|||
}
|
||||
final ignoredCollections =
|
||||
CollectionsService.instance.archivedOrHiddenCollectionIds();
|
||||
final files = await _filesDB.getFilesCreatedWithinDurations(
|
||||
final files = await _filesDB.getFilesCreatedWithinDurationsSync(
|
||||
durations,
|
||||
ignoredCollections,
|
||||
visibility: visibleVisibility,
|
||||
|
|
20
pubspec.lock
20
pubspec.lock
|
@ -1931,10 +1931,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: sqflite_common
|
||||
sha256: "8ed044102f3135add97be8653662052838859f5400075ef227f8ad72ae320803"
|
||||
sha256: bb4738f15b23352822f4c42a531677e5c6f522e079461fd240ead29d8d8a54a6
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.0+1"
|
||||
version: "2.5.0+2"
|
||||
sqflite_migration:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -1943,6 +1943,22 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.0"
|
||||
sqlite3:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3
|
||||
sha256: db65233e6b99e99b2548932f55a987961bc06d82a31a0665451fa0b4fff4c3fb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
sqlite3_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3_flutter_libs
|
||||
sha256: "90963b515721d6a71e96f438175cf43c979493ed14822860a300b69694c74eb6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.19+1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -12,7 +12,7 @@ description: ente photos application
|
|||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
|
||||
version: 0.8.38+558
|
||||
version: 0.8.42+562
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
@ -140,6 +140,8 @@ dependencies:
|
|||
shared_preferences: ^2.0.5
|
||||
sqflite: ^2.3.0
|
||||
sqflite_migration: ^0.3.0
|
||||
sqlite3: ^2.1.0
|
||||
sqlite3_flutter_libs: ^0.5.19+1
|
||||
step_progress_indicator: ^1.0.2
|
||||
styled_text: ^7.0.0
|
||||
syncfusion_flutter_core: ^19.2.49
|
||||
|
|
1
thirdparty/isar
vendored
Submodule
1
thirdparty/isar
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 6643d064abf22606b6c6a741ea873e4781115ef4
|
Loading…
Add table
Reference in a new issue