Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Display error message when transferring files that are too large for FAT32 #13137

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/Files.App/Dialogs/FileTooLargeDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!-- Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE. -->
<ContentDialog
x:Class="Files.App.Dialogs.FileTooLargeDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Files.App.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{helpers:ResourceString Name=StatusCopyFailed}"
ferrariofilippo marked this conversation as resolved.
Show resolved Hide resolved
CornerRadius="{StaticResource OverlayCornerRadius}"
DefaultButton="Primary"
PrimaryButtonText="{helpers:ResourceString Name=OK}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

<StackPanel Spacing="4">
<TextBlock Text="{x:Bind ViewModel.ListHeader}" />

<ListView
MaxHeight="300"
ItemsSource="{x:Bind ViewModel.Paths}"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<TextBlock
Padding="4"
IsTabStop="False"
Text="{x:Bind}"
TextWrapping="Wrap" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>

</ContentDialog>
35 changes: 35 additions & 0 deletions src/Files.App/Dialogs/FileTooLargeDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml.Controls;

namespace Files.App.Dialogs
{
public sealed partial class FileTooLargeDialog : ContentDialog, IDialog<FileTooLargeDialogViewModel>
{
public FileTooLargeDialogViewModel ViewModel
{
get => (FileTooLargeDialogViewModel)DataContext;
set => DataContext = value;
}

public FileTooLargeDialog()
{
InitializeComponent();
}

public new async Task<DialogResult> ShowAsync()
{
return (DialogResult)await SetContentDialogRoot(this).TryShowAsync();
}

// WINUI3
private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
{
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

return contentDialog;
}
}
}
1 change: 1 addition & 0 deletions src/Files.App/Services/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public DialogService()
{ typeof(ReorderSidebarItemsDialogViewModel), () => new ReorderSidebarItemsDialog() },
{ typeof(AddBranchDialogViewModel), () => new AddBranchDialog() },
{ typeof(GitHubLoginDialogViewModel), () => new GitHubLoginDialog() },
{ typeof(FileTooLargeDialogViewModel), () => new FileTooLargeDialog() },
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3429,4 +3429,7 @@
<data name="ShortcutItemWorkingDir" xml:space="preserve">
<value>Start in:</value>
</data>
<data name="FileTooLargeHeader" xml:space="preserve">
<value>The following files are too big to be copied on ({0}):</value>
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ await sourceMatch.Select(x => x.dest).ToListAsync(),
await sourceMatch.Select(x => FileNameConflictResolveOptionType.ReplaceExisting).ToListAsync(), progress, cancellationToken);
}
}
else if (copyResult.Items.Any(x => CopyEngineResult.Convert(x.HResult) == FileSystemStatusCode.FileTooLarge))
{
var failingItems = copyResult.Items
.Where(x => CopyEngineResult.Convert(x.HResult) == FileSystemStatusCode.FileTooLarge)
.Select(item => item.Source);

await Ioc.Default.GetRequiredService<IDialogService>().ShowDialogAsync(new FileTooLargeDialogViewModel(
string.Format("FileTooLargeHeader".GetLocalizedResource(), Path.GetPathRoot(copyResult.Items.First().Destination)),
failingItems
));
}
// ADS
else if (copyResult.Items.All(x => x.HResult == -1))
{
Expand Down
3 changes: 2 additions & 1 deletion src/Files.Core/Data/Enums/CopyEngineResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct CopyEngineResult
public const int COPYENGINE_E_ALREADY_EXISTS_SYSTEM = -2144927701;
public const int COPYENGINE_E_ALREADY_EXISTS_FOLDER = -2144927700;
// File too big
//public const int COPYENGINE_E_FILE_TOO_LARGE = -2144927731;
public const int COPYENGINE_E_FILE_TOO_LARGE = -2144927731;
//public const int COPYENGINE_E_REMOVABLE_FULL = -2144927730;
//public const int COPYENGINE_E_DISK_FULL = -2144927694;
//public const int COPYENGINE_E_DISK_FULL_CLEAN = -2144927693;
Expand Down Expand Up @@ -78,6 +78,7 @@ public static FileSystemStatusCode Convert(int? hres)
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_READONLY => FileSystemStatusCode.AlreadyExists,
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_SYSTEM => FileSystemStatusCode.AlreadyExists,
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_FOLDER => FileSystemStatusCode.AlreadyExists,
CopyEngineResult.COPYENGINE_E_FILE_TOO_LARGE => FileSystemStatusCode.FileTooLarge,
CopyEngineResult.COPYENGINE_E_FILE_IS_FLD_DEST => FileSystemStatusCode.NotAFile,
CopyEngineResult.COPYENGINE_E_FLD_IS_FILE_DEST => FileSystemStatusCode.NotAFolder,
CopyEngineResult.COPYENGINE_E_SHARING_VIOLATION_SRC => FileSystemStatusCode.InUse,
Expand Down
7 changes: 6 additions & 1 deletion src/Files.Core/Data/Enums/FileSystemStatusCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public enum FileSystemStatusCode
/// <summary>
/// InProgress
/// </summary>
InProgress = 1024
InProgress = 1024,

/// <summary>
/// FileTooLarge
/// </summary>
FileTooLarge = 2048
}
}
18 changes: 18 additions & 0 deletions src/Files.Core/ViewModels/Dialogs/FileTooLargeDialogViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.Core.ViewModels.Dialogs
{
public sealed class FileTooLargeDialogViewModel: ObservableObject
{
public string ListHeader { get; private set; }

public IEnumerable<string> Paths { get; private set; }

public FileTooLargeDialogViewModel(string listHeader, IEnumerable<string> paths)
{
ListHeader = listHeader;
Paths = paths;
}
}
}