Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Improve assertion checks for move ops

Neeraj Gupta4ce6c8592ed8
diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart
index 5cceece1b5..ae8ae150fb 100644
--- a/lib/services/collections_service.dart
+++ b/lib/services/collections_service.dart
@@ -1443,9 +1443,19 @@ class CollectionsService {
int fromCollectionID,
List<EnteFile> files,
) {
+ final int userID = Configuration.instance.getUserID()!;
if (toCollectionID == fromCollectionID) {
throw AssertionError("Can't move to same album");
}
+ final Collection? toCollection = _collectionIDToCollections[toCollectionID];
+ final Collection? fromCollection =
+ _collectionIDToCollections[fromCollectionID];
+ if (toCollection != null && !toCollection.isOwner(userID)) {
+ throw AssertionError("Can't move to a collection you don't own");
+ }
+ if (fromCollection != null && !fromCollection.isOwner(userID)) {
+ throw AssertionError("Can't move from a collection you don't own");
+ }
for (final file in files) {
if (file.uploadedFileID == null) {
throw AssertionError("Can only move uploaded memories");