Skip to content

Commit afcd8b4

Browse files
authored
Fix: Fixed issue where some file operations would fail (#15139)
1 parent 0e145be commit afcd8b4

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/Files.App/Data/Items/ListedItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public string[] FileTags
102102
{
103103
Debug.Assert(value != null);
104104
var dbInstance = FileTagsHelper.GetDbInstance();
105-
dbInstance.SetTags(ItemPath, FileFRN, value);
105+
dbInstance.SetTags(ItemPath, FileFRN, value ?? []);
106106
HasTags = !FileTags.IsEmpty();
107107
FileTagsHelper.WriteFileTag(ItemPath, value);
108108
OnPropertyChanged(nameof(FileTagsUI));

src/Files.App/Data/Models/ItemViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () =>
10361036
private static void SetFileTag(ListedItem item)
10371037
{
10381038
var dbInstance = FileTagsHelper.GetDbInstance();
1039-
dbInstance.SetTags(item.ItemPath, item.FileFRN, item.FileTags);
1039+
dbInstance.SetTags(item.ItemPath, item.FileFRN, item.FileTags ?? []);
10401040
}
10411041

10421042
// This works for recycle bin as well as GetFileFromPathAsync/GetFolderFromPathAsync work

src/Files.App/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ async Task PerformNavigationAsync(string payload, string selectItem = null)
290290
.OnSuccess(item => FileTagsHelper.GetFileFRN(item));
291291
if (fileFRN is not null)
292292
{
293-
var tagUid = tag is not null ? new[] { tag.Uid } : null;
293+
var tagUid = tag is not null ? new[] { tag.Uid } : [];
294294
var dbInstance = FileTagsHelper.GetDbInstance();
295295
dbInstance.SetTags(file, fileFRN, tagUid);
296296
FileTagsHelper.WriteFileTag(file, tagUid);

src/Files.App/Utils/FileTags/FileTagsHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static void UpdateTagsDb()
7979
}
8080
else
8181
{
82-
dbInstance.SetTags(null, file.Frn, null);
82+
dbInstance.SetTags(null, file.Frn, []);
8383
}
8484
}
8585
else
@@ -94,12 +94,12 @@ public static void UpdateTagsDb()
9494
dbInstance.SetTags(file.FilePath, frn, tag);
9595
}, App.Logger))
9696
{
97-
dbInstance.SetTags(file.FilePath, null, null);
97+
dbInstance.SetTags(file.FilePath, null, []);
9898
}
9999
}
100100
else
101101
{
102-
dbInstance.SetTags(file.FilePath, null, null);
102+
dbInstance.SetTags(file.FilePath, null, []);
103103
}
104104
}
105105
}

src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e
854854
};
855855
if (destination is null)
856856
{
857-
dbInstance.SetTags(sourcePath, null, null); // remove tag from deleted files
857+
dbInstance.SetTags(sourcePath, null, []); // remove tag from deleted files
858858
}
859859
else
860860
{
@@ -864,7 +864,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e
864864
{
865865
var tag = dbInstance.GetTags(sourcePath, null);
866866

867-
dbInstance.SetTags(destination, FileTagsHelper.GetFileFRN(destination), tag); // copy tag to new files
867+
dbInstance.SetTags(destination, FileTagsHelper.GetFileFRN(destination), tag ?? []); // copy tag to new files
868868
using var si = new ShellItem(destination);
869869
if (si.IsFolder) // File tag is not copied automatically for folders
870870
{
@@ -882,7 +882,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e
882882
var tags = dbInstance.GetAllUnderPath(sourcePath).ToList();
883883
if (destination is null) // remove tag for items contained in the folder
884884
{
885-
tags.ForEach(t => dbInstance.SetTags(t.FilePath, null, null));
885+
tags.ForEach(t => dbInstance.SetTags(t.FilePath, null, []));
886886
}
887887
else
888888
{
@@ -893,7 +893,7 @@ private static void UpdateFileTagsDb(ShellFileOperations2.ShellFileOpEventArgs e
893893
SafetyExtensions.IgnoreExceptions(() =>
894894
{
895895
var subPath = t.FilePath.Replace(sourcePath, destination, StringComparison.Ordinal);
896-
dbInstance.SetTags(subPath, FileTagsHelper.GetFileFRN(subPath), t.Tags);
896+
dbInstance.SetTags(subPath, FileTagsHelper.GetFileFRN(subPath), t.Tags ?? []);
897897
}, App.Logger);
898898
});
899899
}

0 commit comments

Comments
 (0)