Skip to content

Commit 5abd467

Browse files
committed
Fix: Fixed crash that would occur when dragging an image from the browser (#13628)
1 parent 33db0d0 commit 5abd467

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Files.App/Utils/StatusCenter/StatusCenterHelper.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public static StatusCenterItem AddCard_Delete(
219219
long totalSize = 0)
220220
{
221221
string? sourceDir = string.Empty;
222-
222+
223223
if (source is not null && source.Any())
224224
sourceDir = PathNormalization.GetParentDir(source.First().Path);
225225

@@ -498,9 +498,15 @@ public static void UpdateCardStrings(StatusCenterItem card)
498498

499499
if (card.Source is not null && card.Source.Any())
500500
{
501-
sourcePath = PathNormalization.GetParentDir(card.Source.First());
502-
sourceDirName = sourcePath.Split('\\').Last();
503-
sourceFileName = card.Source.First().Split('\\').Last();
501+
// Include null check for items that don't have a parent dir
502+
// This can happen when dragging an image from the browser
503+
// https://github.com/files-community/Files/issues/13590
504+
if (card.Source.First() != null)
505+
{
506+
sourcePath = PathNormalization.GetParentDir(card.Source.First());
507+
sourceDirName = sourcePath.Split('\\').Last();
508+
sourceFileName = card.Source.First().Split('\\').Last();
509+
}
504510
}
505511

506512
if (card.Destination is not null && card.Destination.Any())

0 commit comments

Comments
 (0)