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

Fix: Fixed issue where transfer progress was always shown as 0% #11769

Merged
merged 2 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ public async Task<IStorageHistory> CopyItemsAsync(IList<IStorageItemWithPath> so
var copyResult = new ShellOperationResult();
if (sourceRename.Any())
{
var resultItem = await FileOperationsHelpers.CopyItemAsync(sourceRename.Select(s => s.Path).ToArray(), destinationRename.ToArray(), false, NativeWinApiHelper.CoreWindowHandle.ToInt64(), operationID);
var resultItem = await FileOperationsHelpers.CopyItemAsync(sourceRename.Select(s => s.Path).ToArray(), destinationRename.ToArray(), false, NativeWinApiHelper.CoreWindowHandle.ToInt64(), progress, operationID);

result &= (FilesystemResult)resultItem.Item1;

copyResult.Items.AddRange(resultItem.Item2?.Final ?? Enumerable.Empty<ShellOperationItemResult>());
}
if (sourceReplace.Any())
{
var resultItem = await FileOperationsHelpers.CopyItemAsync(sourceReplace.Select(s => s.Path).ToArray(), destinationReplace.ToArray(), true, NativeWinApiHelper.CoreWindowHandle.ToInt64(), operationID, progress);
var resultItem = await FileOperationsHelpers.CopyItemAsync(sourceReplace.Select(s => s.Path).ToArray(), destinationReplace.ToArray(), true, NativeWinApiHelper.CoreWindowHandle.ToInt64(), progress, operationID);

result &= (FilesystemResult)resultItem.Item1;

Expand Down Expand Up @@ -335,7 +335,7 @@ public async Task<IStorageHistory> DeleteItemsAsync(IList<IStorageItemWithPath>
var operationID = Guid.NewGuid().ToString();
using var r = cancellationToken.Register(CancelOperation, operationID, false);

var (success, response) = await FileOperationsHelpers.DeleteItemAsync(deleleFilePaths.ToArray(), permanently, NativeWinApiHelper.CoreWindowHandle.ToInt64(), operationID, progress);
var (success, response) = await FileOperationsHelpers.DeleteItemAsync(deleleFilePaths.ToArray(), permanently, NativeWinApiHelper.CoreWindowHandle.ToInt64(), progress, operationID);

var result = (FilesystemResult)success;
var deleteResult = new ShellOperationResult();
Expand Down Expand Up @@ -449,14 +449,14 @@ public async Task<IStorageHistory> MoveItemsAsync(IList<IStorageItemWithPath> so

if (sourceRename.Any())
{
var (status, response) = await FileOperationsHelpers.MoveItemAsync(sourceRename.Select(s => s.Path).ToArray(), destinationRename.ToArray(), false, NativeWinApiHelper.CoreWindowHandle.ToInt64(), operationID, progress);
var (status, response) = await FileOperationsHelpers.MoveItemAsync(sourceRename.Select(s => s.Path).ToArray(), destinationRename.ToArray(), false, NativeWinApiHelper.CoreWindowHandle.ToInt64(), progress, operationID);

result &= (FilesystemResult)status;
moveResult.Items.AddRange(response?.Final ?? Enumerable.Empty<ShellOperationItemResult>());
}
if (sourceReplace.Any())
{
var (status, response) = await FileOperationsHelpers.MoveItemAsync(sourceReplace.Select(s => s.Path).ToArray(), destinationReplace.ToArray(), true, NativeWinApiHelper.CoreWindowHandle.ToInt64(), operationID, progress);
var (status, response) = await FileOperationsHelpers.MoveItemAsync(sourceReplace.Select(s => s.Path).ToArray(), destinationReplace.ToArray(), true, NativeWinApiHelper.CoreWindowHandle.ToInt64(), progress, operationID);

result &= (FilesystemResult)status;
moveResult.Items.AddRange(response?.Final ?? Enumerable.Empty<ShellOperationItemResult>());
Expand Down Expand Up @@ -663,7 +663,7 @@ public async Task<IStorageHistory> RestoreItemsFromTrashAsync(IList<IStorageItem
using var r = cancellationToken.Register(CancelOperation, operationID, false);

var moveResult = new ShellOperationResult();
var (status, response) = await FileOperationsHelpers.MoveItemAsync(source.Select(s => s.Path).ToArray(), destination.ToArray(), false, NativeWinApiHelper.CoreWindowHandle.ToInt64(), operationID, progress);
var (status, response) = await FileOperationsHelpers.MoveItemAsync(source.Select(s => s.Path).ToArray(), destination.ToArray(), false, NativeWinApiHelper.CoreWindowHandle.ToInt64(), progress, operationID);

var result = (FilesystemResult)status;
moveResult.Items.AddRange(response?.Final ?? Enumerable.Empty<ShellOperationItemResult>());
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Helpers/FileOperationsHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera
});
}

public static Task<(bool, ShellOperationResult)> DeleteItemAsync(string[] fileToDeletePath, bool permanently, long ownerHwnd, string operationID = "", IProgress<FileSystemProgress>? progress = default)
public static Task<(bool, ShellOperationResult)> DeleteItemAsync(string[] fileToDeletePath, bool permanently, long ownerHwnd, IProgress<FileSystemProgress> progress, string operationID = "")
{
operationID = string.IsNullOrEmpty(operationID) ? Guid.NewGuid().ToString() : operationID;

Expand Down Expand Up @@ -347,7 +347,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera
});
}

public static Task<(bool, ShellOperationResult)> MoveItemAsync(string[] fileToMovePath, string[] moveDestination, bool overwriteOnMove, long ownerHwnd, string operationID = "", IProgress<FileSystemProgress>? progress = default)
public static Task<(bool, ShellOperationResult)> MoveItemAsync(string[] fileToMovePath, string[] moveDestination, bool overwriteOnMove, long ownerHwnd, IProgress<FileSystemProgress> progress, string operationID = "")
{
operationID = string.IsNullOrEmpty(operationID) ? Guid.NewGuid().ToString() : operationID;

Expand Down Expand Up @@ -427,7 +427,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera
});
}

public static Task<(bool, ShellOperationResult)> CopyItemAsync(string[] fileToCopyPath, string[] copyDestination, bool overwriteOnCopy, long ownerHwnd, string operationID = "", IProgress<FileSystemProgress>? progress = default)
public static Task<(bool, ShellOperationResult)> CopyItemAsync(string[] fileToCopyPath, string[] copyDestination, bool overwriteOnCopy, long ownerHwnd, IProgress<FileSystemProgress> progress, string operationID = "")
{
operationID = string.IsNullOrEmpty(operationID) ? Guid.NewGuid().ToString() : operationID;

Expand Down