Skip to content

Commit 4be1ee2

Browse files
authored
Bugfixes (#5961)
1 parent 9004a7b commit 4be1ee2

File tree

13 files changed

+69
-30
lines changed

13 files changed

+69
-30
lines changed

Files/Filesystem/FilesystemOperations/FilesystemOperations.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ private async Task<FilesystemResult> PerformAdminOperation(ValueSet operation)
888888
&& response.Get("Success", false));
889889
var shellOpResult = JsonConvert.DeserializeObject<ShellOperationResult>(response.Get("Result", "{\"Items\": []}"));
890890
fsResult &= (FilesystemResult)shellOpResult.Items.All(x => x.Succeeded);
891+
return fsResult;
891892
}
892893
}
893894
}

Files/Filesystem/ListedItem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Windows.Storage;
1515
using Windows.UI.Xaml.Media.Imaging;
1616
using Files.Filesystem.StorageItems;
17+
using System.Linq;
1718

1819
namespace Files.Filesystem
1920
{
@@ -335,7 +336,7 @@ public override string ToString()
335336
public bool IsFtpItem => this is FtpItem;
336337
public bool IsZipItem => this is ZipItem;
337338

338-
public virtual bool IsExecutable => Path.GetExtension(ItemPath)?.ToLower() == ".exe";
339+
public virtual bool IsExecutable => new[] { ".exe", ".bat", ".cmd" }.Contains(Path.GetExtension(ItemPath), StringComparer.OrdinalIgnoreCase);
339340
public bool IsPinned => App.SidebarPinnedController.Model.FavoriteItems.Contains(itemPath);
340341

341342
private BaseStorageFile itemFile;

Files/Helpers/ContextFlyoutItemHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
629629
Tag = "OpenWith",
630630
CollapseLabel = true,
631631
ShowInSearchPage = true,
632-
ShowItem = selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.File && !i.IsShortcutItem),
632+
ShowItem = selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.File && !i.IsShortcutItem && !i.IsExecutable),
633633
},
634634
new ContextMenuFlyoutItemViewModel()
635635
{
@@ -645,7 +645,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
645645
}
646646
},
647647
ShowInSearchPage = true,
648-
ShowItem = selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.File && !i.IsShortcutItem),
648+
ShowItem = selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.File && !i.IsShortcutItem && !i.IsExecutable),
649649
},
650650
new ContextMenuFlyoutItemViewModel()
651651
{

Files/Helpers/ItemListDisplayHelpers/SortingHelper.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ public static IEnumerable<ListedItem> OrderFileList(List<ListedItem> filesAndFol
5252
ordered = filesAndFolders.OrderBy(folderThenFileAsync).ThenBy(orderFunc, naturalStringComparer);
5353
}
5454
}
55+
else if (directorySortOption == SortOption.FileTag)
56+
{
57+
if (App.AppSettings.ListAndSortDirectoriesAlongsideFiles)
58+
{
59+
ordered = filesAndFolders.OrderBy(x => string.IsNullOrEmpty(orderFunc(x) as string)).ThenBy(orderFunc);
60+
}
61+
else
62+
{
63+
ordered = filesAndFolders.OrderBy(folderThenFileAsync).ThenBy(x => string.IsNullOrEmpty(orderFunc(x) as string)).ThenBy(orderFunc);
64+
}
65+
}
5566
else
5667
{
5768
if (App.AppSettings.ListAndSortDirectoriesAlongsideFiles)
@@ -77,6 +88,17 @@ public static IEnumerable<ListedItem> OrderFileList(List<ListedItem> filesAndFol
7788
ordered = filesAndFolders.OrderBy(folderThenFileAsync).ThenByDescending(orderFunc, naturalStringComparer);
7889
}
7990
}
91+
else if (directorySortOption == SortOption.FileTag)
92+
{
93+
if (App.AppSettings.ListAndSortDirectoriesAlongsideFiles)
94+
{
95+
ordered = filesAndFolders.OrderBy(x => string.IsNullOrEmpty(orderFunc(x) as string)).ThenByDescending(orderFunc);
96+
}
97+
else
98+
{
99+
ordered = filesAndFolders.OrderBy(folderThenFileAsync).ThenBy(x => string.IsNullOrEmpty(orderFunc(x) as string)).ThenByDescending(orderFunc);
100+
}
101+
}
80102
else
81103
{
82104
if (App.AppSettings.ListAndSortDirectoriesAlongsideFiles)

Files/Helpers/NavigationHelpers.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Toolkit.Uwp;
88
using System;
99
using System.Collections.Generic;
10+
using System.Linq;
1011
using System.Threading.Tasks;
1112
using Windows.ApplicationModel.AppService;
1213
using Windows.ApplicationModel.Core;
@@ -74,7 +75,7 @@ public static async void OpenSelectedItems(IShellPage associatedInstance, bool o
7475
{
7576
return;
7677
}
77-
foreach (ListedItem item in associatedInstance.SlimContentPage.SelectedItems)
78+
foreach (ListedItem item in associatedInstance.SlimContentPage.SelectedItems.ToList())
7879
{
7980
var type = item.PrimaryItemAttribute == StorageItemTypes.Folder ?
8081
FilesystemItemType.Directory : FilesystemItemType.File;

Files/Interacts/BaseLayoutCommandImplementationModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,11 @@ public async void DecompressArchive()
669669
if (destinationFolder == null)
670670
{
671671
BaseStorageFolder parentFolder = await StorageItemHelpers.ToStorageItem<BaseStorageFolder>(Path.GetDirectoryName(archive.Path));
672-
destinationFolder = await parentFolder.CreateFolderAsync(Path.GetFileName(destinationFolderPath), CreationCollisionOption.GenerateUniqueName);
672+
destinationFolder = await FilesystemTasks.Wrap(() => parentFolder.CreateFolderAsync(Path.GetFileName(destinationFolderPath), CreationCollisionOption.GenerateUniqueName).AsTask());
673+
}
674+
if (destinationFolder == null)
675+
{
676+
return; // Could not create dest folder
673677
}
674678

675679
Stopwatch sw = new Stopwatch();
@@ -742,7 +746,7 @@ public async void DecompressArchiveToChildFolder()
742746

743747
if (currentFolder != null)
744748
{
745-
destinationFolder = await currentFolder.CreateFolderAsync(Path.GetFileNameWithoutExtension(archive.Path), CreationCollisionOption.OpenIfExists);
749+
destinationFolder = await FilesystemTasks.Wrap(() => currentFolder.CreateFolderAsync(Path.GetFileNameWithoutExtension(archive.Path), CreationCollisionOption.OpenIfExists).AsTask());
746750
}
747751

748752
if (archive != null && destinationFolder != null)

Files/UserControls/ColoredIcon.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</ResourceDictionary>
2626
<ResourceDictionary x:Key="HighContrast">
2727
<SolidColorBrush x:Key="ColoredIconOverlayForeground" Color="{ThemeResource SystemAccentColor}" />
28-
<SolidColorBrush x:Key="ColoredIconOverlayDisabled" Color="{ThemeResource SystemAccentColorDark1}" />
28+
<SolidColorBrush x:Key="ColoredIconOverlayForegroundDisabled" Color="{ThemeResource SystemAccentColorDark1}" />
2929
<SolidColorBrush x:Key="ColoredIconOverlayForegroundChecked" Color="{ThemeResource SystemAccentColor}" />
3030
</ResourceDictionary>
3131
</ResourceDictionary.ThemeDictionaries>

Files/UserControls/Widgets/FolderWidget.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void Dispose()
140140

141141
private async Task GetItemsAddedIcon()
142142
{
143-
foreach (var item in ItemsAdded)
143+
foreach (var item in ItemsAdded.ToList())
144144
{
145145
item.SelectCommand = LibraryCardClicked;
146146
item.AutomationProperties = item.Text;

Files/ViewModels/Properties/FileProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static async Task<string> GetAddressFromCoordinatesAsync(double? Lat, dou
217217
// Reverse geocode the specified geographic location.
218218

219219
var result = await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);
220-
return result != null ? result.Locations[0].DisplayName : null;
220+
return result?.Locations?.FirstOrDefault()?.DisplayName;
221221
}
222222

223223
public async Task SyncPropertyChangesAsync()

Files/Views/LayoutModes/ColumnViewBrowser.xaml.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,25 +163,18 @@ protected override void UnhookEvents()
163163

164164
private void ColumnViewBase_DismissColumn(object sender, EventArgs e)
165165
{
166+
if ((sender as ListView).FindAscendant<ColumnViewBrowser>() != this)
167+
{
168+
return;
169+
}
166170
DismissOtherBlades(sender as ListView);
167171
}
168172

169173
private void ColumnViewBase_UnFocusPreviousListView(object sender, EventArgs e)
170174
{
171-
var list = sender as ListView;
172-
var blade = list.FindAscendant<BladeItem>();
173-
var index = ColumnHost.ActiveBlades.IndexOf(blade) - 1;
174-
if (index == 0)
175+
if ((sender as ListView).FindAscendant<ColumnViewBrowser>() != this)
175176
{
176-
//_ = VisualStateManager.GoToState(listViewItem, "NotCurrentItem", true);
177-
}
178-
else if (index > 0)
179-
{
180-
Common.Extensions.IgnoreExceptions(() =>
181-
{
182-
//var listview = ColumnHost.ActiveBlades[index].FindDescendant("FileList") as ListView;
183-
//var listViewItem = listview.ContainerFromItem((listview.SelectedItem) as ListedItem) as ListViewItem;
184-
});
177+
return;
185178
}
186179
}
187180

@@ -193,6 +186,10 @@ private void FileList_GotFocus(object sender, RoutedEventArgs e)
193186
private void ColumnViewBase_ItemInvoked(object sender, EventArgs e)
194187
{
195188
var column = sender as ColumnParam;
189+
if (column.ListView.FindAscendant<ColumnViewBrowser>() != this)
190+
{
191+
return;
192+
}
196193

197194
var frame = new Frame();
198195
frame.Navigated += Frame_Navigated;

0 commit comments

Comments
 (0)