Skip to content

armgit / ente

Public Imported from GitHub
0

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

Guard collection repository against self-moves

Neeraj Gupta13ddc07a4528
diff --git a/server/pkg/repo/collection.go b/server/pkg/repo/collection.go
index 16fed67d43..394f745944 100644
--- a/server/pkg/repo/collection.go
+++ b/server/pkg/repo/collection.go
@@ -867,6 +867,9 @@ func (repo *CollectionRepository) MoveFiles(ctx context.Context,
if collectionOwner != fileOwner {
return fmt.Errorf("move is not supported when collection and file onwer are different")
}
+ if toCollectionID == fromCollectionID {
+ return fmt.Errorf("source and destination collections must differ")
+ }
tx, err := repo.DB.BeginTx(ctx, nil)
if err != nil {
return stacktrace.Propagate(err, "")