diff --git a/src/Files.App/Data/Items/ListedItem.cs b/src/Files.App/Data/Items/ListedItem.cs index d7deb502397c..012dca90fb24 100644 --- a/src/Files.App/Data/Items/ListedItem.cs +++ b/src/Files.App/Data/Items/ListedItem.cs @@ -102,7 +102,7 @@ public string[] FileTags { Debug.Assert(value != null); var dbInstance = FileTagsHelper.GetDbInstance(); - dbInstance.SetTags(ItemPath, FileFRN, value); + dbInstance.SetTags(ItemPath, FileFRN, value ?? []); HasTags = !FileTags.IsEmpty(); FileTagsHelper.WriteFileTag(ItemPath, value); OnPropertyChanged(nameof(FileTagsUI)); diff --git a/src/Files.App/Data/Models/ItemViewModel.cs b/src/Files.App/Data/Models/ItemViewModel.cs index 03469d3c7933..0abbd0e2d618 100644 --- a/src/Files.App/Data/Models/ItemViewModel.cs +++ b/src/Files.App/Data/Models/ItemViewModel.cs @@ -1036,7 +1036,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () => private static void SetFileTag(ListedItem item) { var dbInstance = FileTagsHelper.GetDbInstance(); - dbInstance.SetTags(item.ItemPath, item.FileFRN, item.FileTags); + dbInstance.SetTags(item.ItemPath, item.FileFRN, item.FileTags ?? []); } // This works for recycle bin as well as GetFileFromPathAsync/GetFolderFromPathAsync work diff --git a/src/Files.App/MainWindow.xaml.cs b/src/Files.App/MainWindow.xaml.cs index 790e352bd4a5..6030e0900d30 100644 --- a/src/Files.App/MainWindow.xaml.cs +++ b/src/Files.App/MainWindow.xaml.cs @@ -290,7 +290,7 @@ async Task PerformNavigationAsync(string payload, string selectItem = null) .OnSuccess(item => FileTagsHelper.GetFileFRN(item)); if (fileFRN is not null) { - var tagUid = tag is not null ? new[] { tag.Uid } : null; + var tagUid = tag is not null ? new[] { tag.Uid } : []; var dbInstance = FileTagsHelper.GetDbInstance(); dbInstance.SetTags(file, fileFRN, tagUid); FileTagsHelper.WriteFileTag(file, tagUid); diff --git a/src/Files.App/Utils/FileTags/FileTagsHelper.cs b/src/Files.App/Utils/FileTags/FileTagsHelper.cs index f63b8fe5044e..b1eb0d4cd60d 100644 --- a/src/Files.App/Utils/FileTags/FileTagsHelper.cs +++ b/src/Files.App/Utils/FileTags/FileTagsHelper.cs @@ -79,7 +79,7 @@ public static void UpdateTagsDb() } else { - dbInstance.SetTags(null, file.Frn, null); + dbInstance.SetTags(null, file.Frn, []); } } else @@ -94,12 +94,12 @@ public static void UpdateTagsDb() dbInstance.SetTags(file.FilePath, frn, tag); }, App.Logger)) { - dbInstance.SetTags(file.FilePath, null, null); + dbInstance.SetTags(file.FilePath, null, []); } } else { - dbInstance.SetTags(file.FilePath, null, null); + dbInstance.SetTags(file.FilePath, null, []); } } } diff --git a/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs b/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs index 131823ec9d8a..747da26c9351 100644 --- a/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs @@ -854,7 +854,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e }; if (destination is null) { - dbInstance.SetTags(sourcePath, null, null); // remove tag from deleted files + dbInstance.SetTags(sourcePath, null, []); // remove tag from deleted files } else { @@ -864,7 +864,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e { var tag = dbInstance.GetTags(sourcePath, null); - dbInstance.SetTags(destination, FileTagsHelper.GetFileFRN(destination), tag); // copy tag to new files + dbInstance.SetTags(destination, FileTagsHelper.GetFileFRN(destination), tag ?? []); // copy tag to new files using var si = new ShellItem(destination); if (si.IsFolder) // File tag is not copied automatically for folders { @@ -882,7 +882,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e var tags = dbInstance.GetAllUnderPath(sourcePath).ToList(); if (destination is null) // remove tag for items contained in the folder { - tags.ForEach(t => dbInstance.SetTags(t.FilePath, null, null)); + tags.ForEach(t => dbInstance.SetTags(t.FilePath, null, [])); } else { @@ -893,7 +893,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e SafetyExtensions.IgnoreExceptions(() => { var subPath = t.FilePath.Replace(sourcePath, destination, StringComparison.Ordinal); - dbInstance.SetTags(subPath, FileTagsHelper.GetFileFRN(subPath), t.Tags); + dbInstance.SetTags(subPath, FileTagsHelper.GetFileFRN(subPath), t.Tags ?? []); }, App.Logger); }); }