Skip to content

Commit bc0b214

Browse files
authored
Fixed issues found in AppCenter (#2663)
1 parent 6c28336 commit bc0b214

File tree

8 files changed

+52
-38
lines changed

8 files changed

+52
-38
lines changed

Files/Filesystem/FilesystemOperations/FilesystemOperations.cs

+10-7
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,19 @@ await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(iFilePath)
380380
{
381381
// Enumerate Recycle Bin
382382
List<ShellFileItem> items = await recycleBinHelpers.EnumerateRecycleBin();
383-
List<ShellFileItem> nameMatchItems;
383+
List<ShellFileItem> nameMatchItems = new List<ShellFileItem>();
384384

385385
// Get name matching files
386-
if (Path.GetExtension(source.Path) == ".lnk" || Path.GetExtension(source.Path) == ".url") // We need to check if it is a shortcut file
386+
if (items != null)
387387
{
388-
nameMatchItems = items.Where((item) => item.FilePath == Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileNameWithoutExtension(source.Path))).ToList();
389-
}
390-
else
391-
{
392-
nameMatchItems = items.Where((item) => item.FilePath == source.Path).ToList();
388+
if (Path.GetExtension(source.Path) == ".lnk" || Path.GetExtension(source.Path) == ".url") // We need to check if it is a shortcut file
389+
{
390+
nameMatchItems = items.Where((item) => item.FilePath == Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileNameWithoutExtension(source.Path))).ToList();
391+
}
392+
else
393+
{
394+
nameMatchItems = items.Where((item) => item.FilePath == source.Path).ToList();
395+
}
393396
}
394397

395398
// Get newest file

Files/Helpers/JumpListManager.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,17 @@ private Task AddFolder(string path)
9595

9696
public async void RemoveFolder(string path)
9797
{
98-
if (JumpListItemPaths.Contains(path))
98+
// Updating the jumplist may fail randomly with error: FileLoadException: File in use
99+
// In that case app should just catch the error and proceed as usual
100+
try
99101
{
100-
JumpListItemPaths.Remove(path);
101-
await UpdateAsync();
102+
if (JumpListItemPaths.Contains(path))
103+
{
104+
JumpListItemPaths.Remove(path);
105+
await UpdateAsync();
106+
}
102107
}
108+
catch { }
103109
}
104110

105111
private async Task UpdateAsync()

Files/Helpers/RegistryHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static async Task<ShellNewEntry> ParseShellNewRegistryEntry(RegistryKey
100100
.OnSuccess(t => t.CreateFileAsync("file" + extension, CreationCollisionOption.OpenIfExists).AsTask());
101101

102102
var displayType = sampleFile ? sampleFile.Result.DisplayType : string.Format("{0} {1}", "file", extension);
103-
var thumbnail = sampleFile ? await sampleFile.Result.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 24, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale) : null;
103+
var thumbnail = sampleFile ? await FilesystemTasks.Wrap(() => sampleFile.Result.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 24, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale).AsTask()) : null;
104104

105105
var entry = new ShellNewEntry()
106106
{

Files/View Models/ItemViewModel.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,10 @@ public async void RapidAddItemsToCollectionAsync(string path, string previousDir
848848
}
849849
}
850850
}
851+
catch (ObjectDisposedException ex)
852+
{
853+
NLog.LogManager.GetCurrentClassLogger().Warn(ex, ex.Message);
854+
}
851855
finally
852856
{
853857
semaphoreSlim.Release();
@@ -1169,7 +1173,11 @@ private async Task EnumFromStorageFolderAsync()
11691173
break;
11701174
}
11711175
}
1172-
catch (UnauthorizedAccessException)
1176+
catch (NotImplementedException)
1177+
{
1178+
break;
1179+
}
1180+
catch (Exception ex) when (ex is UnauthorizedAccessException || ex is FileNotFoundException)
11731181
{
11741182
++count;
11751183
continue;

Files/View Models/SelectedItemsPropertiesViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ public async void CheckFileExtension()
540540
IsSelectedItemShortcut = false;
541541

542542
//check if the selected item is an image file
543-
string ItemExtension = await CoreApplication.MainView.ExecuteOnUIThreadAsync(() => contentPage.SelectedItem.FileExtension);
543+
string ItemExtension = await CoreApplication.MainView.ExecuteOnUIThreadAsync(() => contentPage?.SelectedItem?.FileExtension);
544544
if (!string.IsNullOrEmpty(ItemExtension) && SelectedItemsCount == 1)
545545
{
546546
if (ItemExtension.Equals(".png", StringComparison.OrdinalIgnoreCase)

Files/Views/ModernShellPage.xaml.cs

+14-19
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,21 @@ private void ModernShellPage_BackNavRequested(object sender, EventArgs e)
211211

212212
private async void SidebarControl_RecycleBinItemRightTapped(object sender, EventArgs e)
213213
{
214-
var value = new ValueSet
214+
var recycleBinHasItems = false;
215+
if (ServiceConnection != null)
216+
{
217+
var value = new ValueSet
215218
{
216219
{ "Arguments", "RecycleBin" },
217220
{ "action", "Query" }
218221
};
219-
220-
var response = await ServiceConnection.SendMessageAsync(value);
221-
if (response.Status == AppServiceResponseStatus.Success && response.Message.TryGetValue("NumItems", out var numItems))
222-
{
223-
SidebarControl.RecycleBinHasItems = (long)numItems > 0;
224-
}
225-
else
226-
{
227-
SidebarControl.RecycleBinHasItems = false;
222+
var response = await ServiceConnection.SendMessageAsync(value);
223+
if (response.Status == AppServiceResponseStatus.Success && response.Message.TryGetValue("NumItems", out var numItems))
224+
{
225+
recycleBinHasItems = (long)numItems > 0;
226+
}
228227
}
228+
SidebarControl.RecycleBinHasItems = recycleBinHasItems;
229229
}
230230

231231
private async void SidebarControl_SidebarItemDropped(object sender, Controls.SidebarItemDroppedEventArgs e)
@@ -1146,16 +1146,11 @@ public void Up_Click()
11461146
Frame instanceContentFrame = ContentFrame;
11471147
FilesystemViewModel.CancelLoadAndClearFiles();
11481148
var instance = FilesystemViewModel;
1149-
string parentDirectoryOfPath;
1150-
// Check that there isn't a slash at the end
1151-
if ((instance.WorkingDirectory.Count() - 1) - instance.WorkingDirectory.LastIndexOf("\\") > 0)
1152-
{
1153-
parentDirectoryOfPath = instance.WorkingDirectory.Remove(instance.WorkingDirectory.LastIndexOf("\\"));
1154-
}
1155-
else // Slash found at end
1149+
string parentDirectoryOfPath = instance.WorkingDirectory.TrimEnd('\\');
1150+
var lastSlashIndex = parentDirectoryOfPath.LastIndexOf("\\");
1151+
if (lastSlashIndex != -1)
11561152
{
1157-
var currentPathWithoutEndingSlash = instance.WorkingDirectory.Remove(instance.WorkingDirectory.LastIndexOf("\\"));
1158-
parentDirectoryOfPath = currentPathWithoutEndingSlash.Remove(currentPathWithoutEndingSlash.LastIndexOf("\\"));
1153+
parentDirectoryOfPath = instance.WorkingDirectory.Remove(lastSlashIndex);
11591154
}
11601155

11611156
SelectSidebarItemFromPath();

Files/Views/Pages/Properties.xaml.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public sealed partial class Properties : Page
3636
public Properties()
3737
{
3838
InitializeComponent();
39-
propertiesDialog = Interaction.FindParent<ContentDialog>(this);
4039
}
4140

4241
protected override void OnNavigatedTo(NavigationEventArgs e)
@@ -67,6 +66,7 @@ private async void Properties_Loaded(object sender, RoutedEventArgs e)
6766
}
6867
else
6968
{
69+
propertiesDialog = Interaction.FindParent<ContentDialog>(this);
7070
propertiesDialog.Closed += PropertiesDialog_Closed;
7171
}
7272
}
@@ -194,7 +194,7 @@ private async void OKButton_Click(object sender, RoutedEventArgs e)
194194
}
195195
else
196196
{
197-
propertiesDialog.Hide();
197+
propertiesDialog?.Hide();
198198
}
199199
}
200200

@@ -206,7 +206,7 @@ private async void CancelButton_Click(object sender, RoutedEventArgs e)
206206
}
207207
else
208208
{
209-
propertiesDialog.Hide();
209+
propertiesDialog?.Hide();
210210
}
211211
}
212212

@@ -220,7 +220,7 @@ private async void Page_KeyDown(object sender, KeyRoutedEventArgs e)
220220
}
221221
else
222222
{
223-
propertiesDialog.Hide();
223+
propertiesDialog?.Hide();
224224
}
225225
}
226226
}

Files/Views/SettingsPages/About.xaml.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ private async void FeedbackListView_Tapped(object sender, Windows.UI.Xaml.Input.
3636
{
3737
await Launcher.LaunchUriAsync(new Uri(@"https://paypal.me/yaichenbaum"));
3838
}
39-
40-
(FeedbackListView.Items[FeedbackListView.SelectedIndex] as ListViewItem).IsSelected = false;
39+
if (FeedbackListView.SelectedIndex != -1)
40+
{
41+
(FeedbackListView.Items[FeedbackListView.SelectedIndex] as ListViewItem).IsSelected = false;
42+
}
4143
}
4244
}
4345
}

0 commit comments

Comments
 (0)