Skip to content

Commit 30a5435

Browse files
authored
Prevent addition of item if failed to retrieve find data (#2823)
1 parent d665d3b commit 30a5435

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Files/ViewModels/ItemViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,13 @@ private async Task AddFileOrFolderAsync(string fileOrFolderPath, string dateRetu
15531553

15541554
IntPtr hFile = FindFirstFileExFromApp(fileOrFolderPath, findInfoLevel, out WIN32_FIND_DATA findData, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero,
15551555
additionalFlags);
1556+
if (hFile.ToInt64() == -1)
1557+
{
1558+
// If we cannot find the file (probably since it doesn't exist anymore)
1559+
// simply exit without adding it
1560+
return;
1561+
}
1562+
15561563
FindClose(hFile);
15571564

15581565
ListedItem listedItem = null;

0 commit comments

Comments
 (0)