diff --git a/Iceshrimp.Backend/Controllers/Web/DriveController.cs b/Iceshrimp.Backend/Controllers/Web/DriveController.cs index ff8d6677..e3a899da 100644 --- a/Iceshrimp.Backend/Controllers/Web/DriveController.cs +++ b/Iceshrimp.Backend/Controllers/Web/DriveController.cs @@ -241,7 +241,8 @@ public class DriveController( [Authenticate] [Authorize] [ProducesResults(HttpStatusCode.OK)] - [ProducesErrors(HttpStatusCode.NotFound)] + [ProducesErrors(HttpStatusCode.NotFound, HttpStatusCode.Conflict)] + [SuppressMessage("Performance", "CA1862", Justification = "string.Equals() cannot be used in DbSet LINQ operations")] public async Task UpdateFileParent(string id, DriveMoveRequest request) { var user = HttpContext.GetUserOrFail(); @@ -258,6 +259,13 @@ public class DriveController( throw GracefulException.NotFound("The new parent folder doesn't exist"); } + var existing = await db.DriveFiles + .AnyAsync(p => p.Name.ToLower() == file.Name.ToLower() + && p.FolderId == request.FolderId + && p.UserId == user.Id); + if (existing) + throw GracefulException.Conflict("A file with this name already exists in this folder"); + file.FolderId = request.FolderId; await db.SaveChangesAsync();