Skip to content
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
2 changes: 1 addition & 1 deletion src/Files.App/Data/Items/WidgetFileTagsContainerItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public WidgetFileTagsContainerItem(string tagUid)
/// <inheritdoc/>
public async Task InitAsync(CancellationToken cancellationToken = default)
{
await foreach (var item in FileTagsService.GetItemsForTagAsync(_tagUid))
await foreach (var item in FileTagsService.GetItemsForTagAsync(_tagUid, cancellationToken))
{
var icon = await ImageService.GetIconAsync(item.Storable, default);
Tags.Add(new(item.Storable, icon));
Expand Down
24 changes: 12 additions & 12 deletions src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ await DialogDisplayHelper.ShowDialogAsync(
{
// CopyFileFromApp only works on file not directories
var fsSourceFolder = await source.ToStorageItemResult();
var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination));
var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination), cancellationToken);
var fsResult = (FilesystemResult)(fsSourceFolder.ErrorCode | fsDestinationFolder.ErrorCode);

if (fsResult)
Expand Down Expand Up @@ -219,7 +219,7 @@ await DialogDisplayHelper.ShowDialogAsync(
{
Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error());

FilesystemResult<BaseStorageFolder> destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination));
FilesystemResult<BaseStorageFolder> destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination), cancellationToken);
var sourceResult = await source.ToStorageItemResult();
fsResult = sourceResult.ErrorCode | destinationResult.ErrorCode;

Expand Down Expand Up @@ -373,7 +373,7 @@ await DialogDisplayHelper.ShowDialogAsync(
Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error());

var fsSourceFolder = await source.ToStorageItemResult();
var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination));
var fsDestinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination), cancellationToken);
fsResult = fsSourceFolder.ErrorCode | fsDestinationFolder.ErrorCode;

if (fsResult)
Expand Down Expand Up @@ -432,7 +432,7 @@ await DialogDisplayHelper.ShowDialogAsync(
{
Debug.WriteLine(System.Runtime.InteropServices.Marshal.GetLastWin32Error());

FilesystemResult<BaseStorageFolder> destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination));
FilesystemResult<BaseStorageFolder> destinationResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination), cancellationToken);
var sourceResult = await source.ToStorageItemResult();
fsResult = sourceResult.ErrorCode | destinationResult.ErrorCode;

Expand Down Expand Up @@ -512,12 +512,12 @@ public async Task<IStorageHistory> DeleteAsync(IStorageItemWithPath source, IPro
{
if (source.ItemType == FilesystemItemType.File)
{
fsResult = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path)
fsResult = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path, cancellationToken)
.OnSuccess((t) => t.DeleteAsync(permanently ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default).AsTask());
}
else if (source.ItemType == FilesystemItemType.Directory)
{
fsResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path)
fsResult = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path, cancellationToken)
.OnSuccess((t) => t.DeleteAsync(permanently ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default).AsTask());
}
}
Expand All @@ -539,7 +539,7 @@ public async Task<IStorageHistory> DeleteAsync(IStorageItemWithPath source, IPro
// Recycle bin also stores a file starting with $I for each item
string iFilePath = Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileName(source.Path).Replace("$R", "$I", StringComparison.Ordinal));

await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath)
await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath, cancellationToken)
.OnSuccess(iFile => iFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask());
}
fsProgress.ReportStatus(fsResult);
Expand Down Expand Up @@ -738,8 +738,8 @@ public async Task<IStorageHistory> RestoreFromTrashAsync(IStorageItemWithPath so
{
if (source.ItemType == FilesystemItemType.Directory)
{
FilesystemResult<BaseStorageFolder> sourceFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path);
FilesystemResult<BaseStorageFolder> destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination));
FilesystemResult<BaseStorageFolder> sourceFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(source.Path, cancellationToken);
FilesystemResult<BaseStorageFolder> destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination), cancellationToken);

fsResult = sourceFolder.ErrorCode | destinationFolder.ErrorCode;
fsProgress.ReportStatus(fsResult);
Expand All @@ -759,8 +759,8 @@ public async Task<IStorageHistory> RestoreFromTrashAsync(IStorageItemWithPath so
}
else
{
FilesystemResult<BaseStorageFile> sourceFile = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path);
FilesystemResult<BaseStorageFolder> destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination));
FilesystemResult<BaseStorageFile> sourceFile = await _associatedInstance.ShellViewModel.GetFileFromPathAsync(source.Path, cancellationToken);
FilesystemResult<BaseStorageFolder> destinationFolder = await _associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(destination), cancellationToken);

fsResult = sourceFile.ErrorCode | destinationFolder.ErrorCode;
fsProgress.ReportStatus(fsResult);
Expand All @@ -782,7 +782,7 @@ public async Task<IStorageHistory> RestoreFromTrashAsync(IStorageItemWithPath so
// Recycle bin also stores a file starting with $I for each item
string iFilePath = Path.Combine(Path.GetDirectoryName(source.Path), Path.GetFileName(source.Path).Replace("$R", "$I", StringComparison.Ordinal));

await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath)
await _associatedInstance.ShellViewModel.GetFileFromPathAsync(iFilePath, cancellationToken)
.OnSuccess(iFile => iFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Utils/Storage/Search/FolderSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ await Task.Run(() =>
} while (hasNextFile);

Win32PInvoke.FindClose(hFile);
});
}, token);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Utils/Storage/StorageItems/NativeStorageFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public override IAsyncOperation<BaseStorageFile> CopyAsync(IStorageFolder destin
using (var inStream = await this.OpenStreamForReadAsync())
using (var outStream = await destFile.OpenStreamForWriteAsync())
{
await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
await inStream.CopyToAsync(outStream, cancellationToken);
await outStream.FlushAsync(cancellationToken);
}
}
return destFile;
Expand Down Expand Up @@ -251,8 +251,8 @@ public override IAsyncAction RenameAsync(string desiredName, NameCollisionOption
using (var inStream = await this.OpenStreamForReadAsync())
using (var outStream = await destFile.OpenStreamForWriteAsync())
{
await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
await inStream.CopyToAsync(outStream, cancellationToken);
await outStream.FlushAsync(cancellationToken);
}
await DeleteAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public IAsyncOperation<bool> FlushAsync()

return AsyncInfo.Run<bool>(async (cancellationToken) =>
{
await stream.FlushAsync();
await stream.FlushAsync(cancellationToken);
return true;
});
}
Expand Down
16 changes: 8 additions & 8 deletions src/Files.App/Utils/Storage/StorageItems/SystemStorageFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public override IAsyncOperation<BaseStorageFile> CopyAsync(IStorageFolder destin
using (var inStream = await this.OpenStreamForReadAsync())
using (var outStream = await destFile.OpenStreamForWriteAsync())
{
await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
await inStream.CopyToAsync(outStream, cancellationToken);
await outStream.FlushAsync(cancellationToken);
}
return destFile;
}
Expand All @@ -96,8 +96,8 @@ public override IAsyncOperation<BaseStorageFile> CopyAsync(IStorageFolder destin
using (var inStream = await this.OpenStreamForReadAsync())
using (var outStream = new FileStream(hFile, FileAccess.Write))
{
await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
await inStream.CopyToAsync(outStream, cancellationToken);
await outStream.FlushAsync(cancellationToken);
}
return new NativeStorageFile(destination, desiredNewName, DateTime.Now);
}
Expand Down Expand Up @@ -143,8 +143,8 @@ public override IAsyncAction CopyAndReplaceAsync(IStorageFile fileToReplace)
using var inStream = await this.OpenStreamForReadAsync();
using var outStream = await fileToReplace.OpenStreamForWriteAsync();

await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
await inStream.CopyToAsync(outStream, cancellationToken);
await outStream.FlushAsync(cancellationToken);
});
}
public override IAsyncAction MoveAndReplaceAsync(IStorageFile fileToReplace)
Expand All @@ -154,8 +154,8 @@ public override IAsyncAction MoveAndReplaceAsync(IStorageFile fileToReplace)
using var inStream = await this.OpenStreamForReadAsync();
using var outStream = await fileToReplace.OpenStreamForWriteAsync();

await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
await inStream.CopyToAsync(outStream, cancellationToken);
await outStream.FlushAsync(cancellationToken);
// Move unsupported, copy but do not delete original
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public override IAsyncOperation<BaseStorageFile> CopyAsync(IStorageFolder destin
using (var inStream = await this.OpenStreamForReadAsync())
using (var outStream = await destFile.OpenStreamForWriteAsync())
{
await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
await inStream.CopyToAsync(outStream, cancellationToken);
await outStream.FlushAsync(cancellationToken);
}
return destFile;
}
Expand Down