Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/BootstrapBlazor/Components/Upload/DropUpload.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@namespace BootstrapBlazor.Components
@namespace BootstrapBlazor.Components
@inherits FileListUploadBase<string>

@if (IsShowLabel)
Expand Down Expand Up @@ -51,7 +51,8 @@
@if (ShowUploadFileList)
{
<UploadPreviewList Items="Files" IsDisabled="@IsDisabled" ShowProgress="@ShowProgress"
OnGetFileFormat="@OnGetFileFormat" OnCancel="OnCancel" CancelIcon="@CancelIcon" LoadingIcon="@LoadingIcon"
OnGetFileFormat="@OnGetFileFormat" OnCancel="OnCancel"
CancelIcon="@CancelIcon" LoadingIcon="@LoadingIcon"
InvalidStatusIcon="@InvalidStatusIcon" ValidStatusIcon="@ValidStatusIcon"
ShowDownloadButton="@ShowDownloadButton" DownloadIcon="@DownloadIcon" OnDownload="@OnDownload"
DeleteIcon="@DeleteIcon" OnDelete="@OnFileDelete">
Expand Down
10 changes: 8 additions & 2 deletions src/BootstrapBlazor/Components/Upload/UploadBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -283,7 +283,13 @@ protected List<UploadFile> GetUploadFiles()
{
_filesCache.AddRange(DefaultFileList);
}
_filesCache.AddRange(UploadFiles);
UploadFiles.ForEach(f =>
{
if (!_filesCache.Contains(f))
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Contains method will only perform reference equality checks since UploadFile class does not override Equals and GetHashCode. This means the duplicate filter will only prevent adding the exact same object instance, not duplicate files with the same content or properties. If the intent is to prevent duplicate files based on file properties (e.g., FileName, OriginFileName, or File reference), you should either override Equals/GetHashCode in the UploadFile class or use a different comparison method such as LINQ's Any with a custom predicate.

Copilot uses AI. Check for mistakes.
{
_filesCache.Add(f);
}
});
Comment on lines +286 to +292
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new duplicate filter logic lacks test coverage. Consider adding a test case that verifies files are properly deduplicated when the same UploadFile instances are added to both DefaultFileList and UploadFiles, or when GetUploadFiles is called multiple times.

Copilot uses AI. Check for mistakes.
}
return _filesCache;
}
Expand Down
Loading