Improve assertion checks for move ops

This commit is contained in:
Neeraj Gupta 2024-02-22 17:55:40 +05:30
parent e89d32355f
commit 4ce6c8592e

View file

@ -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");