Compare commits
11 Commits
auth-v4.0.
...
photos-v0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa361904f6 | ||
|
|
00e75c0fb2 | ||
|
|
026ab8dcc6 | ||
|
|
7d42ed37e1 | ||
|
|
a5d01a9ffe | ||
|
|
675b7f6cea | ||
|
|
772373580a | ||
|
|
f0a19e38aa | ||
|
|
d1d6590547 | ||
|
|
03da960c33 | ||
|
|
2bdc010849 |
@@ -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:
|
||||
|
||||
@@ -255,7 +255,7 @@ export default function Gallery() {
|
||||
accept: ".zip",
|
||||
});
|
||||
|
||||
const syncInProgress = useRef(true);
|
||||
const syncInProgress = useRef(false);
|
||||
const syncInterval = useRef<NodeJS.Timeout>();
|
||||
const resync = useRef<{ force: boolean; silent: boolean }>();
|
||||
|
||||
@@ -785,6 +785,7 @@ export default function Gallery() {
|
||||
resync.current = { force, silent };
|
||||
return;
|
||||
}
|
||||
const isForced = syncInProgress.current && force;
|
||||
syncInProgress.current = true;
|
||||
try {
|
||||
const token = getToken();
|
||||
@@ -805,7 +806,14 @@ export default function Gallery() {
|
||||
await syncFiles("normal", normalCollections, setFiles);
|
||||
await syncFiles("hidden", hiddenCollections, setHiddenFiles);
|
||||
await syncTrash(collections, setTrashedFiles);
|
||||
await sync();
|
||||
// syncWithRemote is called with the force flag set to true before
|
||||
// doing an upload. So it is possible, say when resuming a pending
|
||||
// upload, that we get two syncWithRemotes happening in parallel.
|
||||
//
|
||||
// Do the non-file-related sync only for one of these parallel ones.
|
||||
if (!isForced) {
|
||||
await sync();
|
||||
}
|
||||
} catch (e) {
|
||||
switch (e.message) {
|
||||
case CustomError.SESSION_EXPIRED:
|
||||
|
||||
Reference in New Issue
Block a user