@@ -107,6 +107,14 @@ class EntityService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> syncEntity(EntityType type) async {
|
||||
try {
|
||||
await _remoteToLocalSync(type);
|
||||
} catch (e) {
|
||||
_logger.severe("Failed to sync entities", e);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _remoteToLocalSync(EntityType type) async {
|
||||
final int lastSyncTime =
|
||||
_prefs.getInt(_getEntityLastSyncTimePrefix(type)) ?? 0;
|
||||
@@ -116,7 +124,6 @@ class EntityService {
|
||||
limit: fetchLimit,
|
||||
);
|
||||
if (result.isEmpty) {
|
||||
debugPrint("No $type entries to sync");
|
||||
return;
|
||||
}
|
||||
final bool hasMoreItems = result.length == fetchLimit;
|
||||
|
||||
@@ -6,6 +6,8 @@ import "package:logging/logging.dart";
|
||||
import "package:photos/core/event_bus.dart";
|
||||
import "package:photos/events/diff_sync_complete_event.dart";
|
||||
import "package:photos/events/people_changed_event.dart";
|
||||
import "package:photos/models/api/entity/type.dart";
|
||||
import "package:photos/services/entity_service.dart";
|
||||
import "package:photos/services/machine_learning/face_ml/face_detection/detection.dart";
|
||||
import "package:photos/services/machine_learning/face_ml/face_detection/face_detection_service.dart";
|
||||
import "package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart";
|
||||
@@ -59,6 +61,7 @@ class FaceRecognitionService {
|
||||
return;
|
||||
}
|
||||
_isSyncing = true;
|
||||
await EntityService.instance.syncEntity(EntityType.cgroup);
|
||||
if (_shouldSyncPeople) {
|
||||
await PersonService.instance.reconcileClusters();
|
||||
Bus.instance.fire(PeopleChangedEvent(type: PeopleEventType.syncDone));
|
||||
|
||||
@@ -335,7 +335,7 @@ class ClusterFeedbackService {
|
||||
}
|
||||
|
||||
Future<void> ignoreCluster(String clusterID) async {
|
||||
await PersonService.instance.addPerson('', clusterID);
|
||||
await PersonService.instance.addPerson('', clusterID, isHidden: true);
|
||||
Bus.instance.fire(PeopleChangedEvent());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import "package:photos/db/ml/db.dart";
|
||||
import "package:photos/events/people_changed_event.dart";
|
||||
import "package:photos/extensions/stop_watch.dart";
|
||||
import "package:photos/models/api/entity/type.dart";
|
||||
import "package:photos/models/file/file.dart";
|
||||
import 'package:photos/models/ml/face/face.dart';
|
||||
import "package:photos/models/ml/face/person.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import "package:photos/services/entity_service.dart";
|
||||
@@ -292,6 +294,24 @@ class PersonService {
|
||||
await faceMLDataDB.bulkAssignClusterToPersonID(clusterToPersonID);
|
||||
}
|
||||
|
||||
Future<void> updateAvatar(PersonEntity p, EnteFile file) async {
|
||||
final Face? face = await MLDataDB.instance.getCoverFaceForPerson(
|
||||
recentFileID: file.uploadedFileID!,
|
||||
personID: p.remoteID,
|
||||
);
|
||||
if (face == null) {
|
||||
throw Exception(
|
||||
"No face found for person ${p.remoteID} in file ${file.uploadedFileID}",
|
||||
);
|
||||
}
|
||||
|
||||
final person = (await getPerson(p.remoteID))!;
|
||||
final updatedPerson = person.copyWith(
|
||||
data: person.data.copyWith(avatarFaceId: face.faceID),
|
||||
);
|
||||
await _updatePerson(updatedPerson);
|
||||
}
|
||||
|
||||
Future<void> updateAttributes(
|
||||
String id, {
|
||||
String? name,
|
||||
|
||||
@@ -121,13 +121,7 @@ class RemoteSyncService {
|
||||
await syncDeviceCollectionFilesForUpload();
|
||||
}
|
||||
await _pullDiff();
|
||||
// sync trash but consume error during initial launch.
|
||||
// this is to ensure that we don't pause upload due to any error during
|
||||
// the trash sync. Impact: We may end up re-uploading a file which was
|
||||
// recently trashed.
|
||||
await TrashSyncService.instance
|
||||
.syncTrash()
|
||||
.onError((e, s) => _logger.severe('trash sync failed', e, s));
|
||||
await TrashSyncService.instance.syncTrash();
|
||||
if (!hasSyncedBefore) {
|
||||
await _prefs.setBool(_isFirstRemoteSyncDone, true);
|
||||
await syncDeviceCollectionFilesForUpload();
|
||||
|
||||
@@ -696,10 +696,7 @@ class _FileSelectionActionsWidgetState
|
||||
|
||||
Future<void> _setPersonCover() async {
|
||||
final EnteFile file = widget.selectedFiles.files.first;
|
||||
await PersonService.instance.updateAttributes(
|
||||
widget.person!.remoteID,
|
||||
avatarFaceId: file.uploadedFileID.toString(),
|
||||
);
|
||||
await PersonService.instance.updateAvatar(widget.person!, file);
|
||||
widget.selectedFiles.clearAll();
|
||||
if (mounted) {
|
||||
setState(() => {});
|
||||
|
||||
@@ -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.9.45+945
|
||||
version: 0.9.46+946
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
|
||||
Reference in New Issue
Block a user