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

Browse zip archives & other things #5885

Merged
merged 15 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 8 additions & 8 deletions Files.Launcher/MessageHandlers/FileOperationsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ await Win32API.StartSTATask(() =>
shellOperationResult.Items.Add(new ShellOperationItemResult()
{
Succeeded = e.Result.Succeeded,
Source = e.SourceItem.FileSystemPath,
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
Destination = e.DestItem?.FileSystemPath,
HRresult = (int)e.Result
});
Expand Down Expand Up @@ -224,7 +224,7 @@ await Win32API.StartSTATask(() =>
shellOperationResult.Items.Add(new ShellOperationItemResult()
{
Succeeded = e.Result.Succeeded,
Source = e.SourceItem.FileSystemPath,
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
Destination = !string.IsNullOrEmpty(e.Name) ? Path.Combine(Path.GetDirectoryName(e.SourceItem.FileSystemPath), e.Name) : null,
HRresult = (int)e.Result
});
Expand Down Expand Up @@ -288,8 +288,8 @@ await Win32API.StartSTATask(() =>
shellOperationResult.Items.Add(new ShellOperationItemResult()
{
Succeeded = e.Result.Succeeded,
Source = e.SourceItem.FileSystemPath,
Destination = e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
Destination = e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
HRresult = (int)e.Result
});
};
Expand Down Expand Up @@ -363,8 +363,8 @@ await Win32API.StartSTATask(() =>
shellOperationResult.Items.Add(new ShellOperationItemResult()
{
Succeeded = e.Result.Succeeded,
Source = e.SourceItem.FileSystemPath,
Destination = e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
Destination = e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
HRresult = (int)e.Result
});
};
Expand Down Expand Up @@ -566,8 +566,8 @@ private void UpdateFileTageDb(object sender, ShellFileOperations.ShellFileOpEven
{
"delete" => e.DestItem?.FileSystemPath,
"rename" => (!string.IsNullOrEmpty(e.Name) ? Path.Combine(Path.GetDirectoryName(e.SourceItem.FileSystemPath), e.Name) : null),
"copy" => (e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null),
_ => (e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null)
"copy" => (e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null),
_ => (e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null)
};
if (destination == null)
{
Expand Down
3 changes: 1 addition & 2 deletions Files.Launcher/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Files.Common;
using FilesFullTrust.Helpers;
using FilesFullTrust.MessageHandlers;
using Newtonsoft.Json;
using System;
Expand Down Expand Up @@ -235,7 +234,7 @@ private static async Task ParseArgumentsAsync(Dictionary<string, object> message
{
await Win32API.SendMessageAsync(connection, new ValueSet() { { "Success", -1 } }, message.Get("RequestID", (string)null));
}
break;
break;

default:
foreach (var mh in messageHandlers)
Expand Down
8 changes: 6 additions & 2 deletions Files/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,14 @@ protected async void FileList_DragItemsStarting(object sender, DragItemsStarting
{
if (item.PrimaryItemAttribute == StorageItemTypes.File)
{
selectedStorageItems.Add(await new FtpStorageFile(ParentShellPageInstance.FilesystemViewModel, ftpItem).ToStorageFileAsync());
selectedStorageItems.Add(await new FtpStorageFile(ftpItem).ToStorageFileAsync());
}
else if (item.PrimaryItemAttribute == StorageItemTypes.Folder)
{
selectedStorageItems.Add(new FtpStorageFolder(ftpItem));
}
}
else if (item.PrimaryItemAttribute == StorageItemTypes.File)
else if (item.PrimaryItemAttribute == StorageItemTypes.File || item is ZipItem)
{
result = await ParentShellPageInstance.FilesystemViewModel.GetFileFromPathAsync(item.ItemPath)
.OnSuccess(t => selectedStorageItems.Add(t));
Expand Down
4 changes: 2 additions & 2 deletions Files/DataModels/FilesystemItemsOperationDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task<List<FilesystemOperationItemViewModel>> ToItems(Action updateP
// Add conflicting items first
foreach (var item in ConflictingItems)
{
var iconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(item.SourcePath, 64u);
var iconData = await FileThumbnailHelper.LoadIconFromPathAsync(item.SourcePath, 64u, Windows.Storage.FileProperties.ThumbnailMode.ListView);

items.Add(new FilesystemOperationItemViewModel(updatePrimaryButtonEnabled, optionGenerateNewName, optionReplaceExisting, optionSkip)
{
Expand All @@ -84,7 +84,7 @@ public async Task<List<FilesystemOperationItemViewModel>> ToItems(Action updateP
// Then add non-conflicting items
foreach (var item in nonConflictingItems)
{
var iconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(item.SourcePath, 64u);
var iconData = await FileThumbnailHelper.LoadIconFromPathAsync(item.SourcePath, 64u, Windows.Storage.FileProperties.ThumbnailMode.ListView);

items.Add(new FilesystemOperationItemViewModel(updatePrimaryButtonEnabled, optionGenerateNewName, optionReplaceExisting, optionSkip)
{
Expand Down
21 changes: 14 additions & 7 deletions Files/DataModels/ShellNewEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Files.Filesystem;
using Files.Filesystem.StorageItems;
using Files.Helpers;
using System;
using System.IO;
using System.Threading.Tasks;
Expand All @@ -16,19 +18,19 @@ public class ShellNewEntry
public byte[] Data { get; set; }
public string Template { get; set; }

public async Task<FilesystemResult<StorageFile>> Create(string filePath, IShellPage associatedInstance)
public async Task<FilesystemResult<BaseStorageFile>> Create(string filePath, IShellPage associatedInstance)
{
var parentFolder = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(Path.GetDirectoryName(filePath));
var parentFolder = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(filePath));
if (parentFolder)
{
return await Create(parentFolder, Path.GetFileName(filePath));
}
return new FilesystemResult<StorageFile>(null, parentFolder.ErrorCode);
return new FilesystemResult<BaseStorageFile>(null, parentFolder.ErrorCode);
}

public async Task<FilesystemResult<StorageFile>> Create(StorageFolder parentFolder, string fileName)
public async Task<FilesystemResult<BaseStorageFile>> Create(BaseStorageFolder parentFolder, string fileName)
{
FilesystemResult<StorageFile> createdFile = null;
FilesystemResult<BaseStorageFile> createdFile = null;
if (!fileName.EndsWith(this.Extension))
{
fileName += this.Extension;
Expand All @@ -39,14 +41,19 @@ public async Task<FilesystemResult<StorageFile>> Create(StorageFolder parentFold
}
else
{
createdFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Template).AsTask())
createdFile = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFileFromPathAsync(Template))
.OnSuccess(t => t.CopyAsync(parentFolder, fileName, NameCollisionOption.GenerateUniqueName).AsTask());
}
if (createdFile)
{
if (this.Data != null)
{
await FileIO.WriteBytesAsync(createdFile.Result, this.Data);
//await FileIO.WriteBytesAsync(createdFile.Result, this.Data); // Calls unsupported OpenTransactedWriteAsync
using (var fileStream = await createdFile.Result.OpenStreamForWriteAsync())
{
await fileStream.WriteAsync(Data, 0, Data.Length);
await fileStream.FlushAsync();
}
}
}
return createdFile;
Expand Down
2 changes: 1 addition & 1 deletion Files/DataModels/SidebarPinnedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public async Task AddItemToSidebarAsync(string path)
locationItem.IconData = iconData;
locationItem.Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => locationItem.IconData.ToBitmapAsync());
}
else
if (locationItem.IconData == null)
{
locationItem.IconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(path, 24u);
if (locationItem.IconData != null)
Expand Down
7 changes: 7 additions & 0 deletions Files/Files.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,15 @@
<Compile Include="Filesystem\Permissions\FileSystemAccessRuleForUI.cs" />
<Compile Include="Filesystem\Permissions\RulesForUser.cs" />
<Compile Include="Filesystem\Permissions\UserGroup.cs" />
<Compile Include="Filesystem\StorageItems\BaseQueryResults.cs" />
<Compile Include="Filesystem\StorageItems\BaseStorageItem.cs" />
<Compile Include="Filesystem\StorageItems\FtpStorageFile.cs" />
<Compile Include="Filesystem\StorageItems\FtpStorageFolder.cs" />
<Compile Include="Filesystem\StorageItems\StreamWithContentType.cs" />
<Compile Include="Filesystem\StorageItems\SystemStorageFile.cs" />
<Compile Include="Filesystem\StorageItems\SystemStorageFolder.cs" />
<Compile Include="Filesystem\StorageItems\ZipStorageFile.cs" />
<Compile Include="Filesystem\StorageItems\ZipStorageFolder.cs" />
<Compile Include="Helpers\FtpHelpers.cs" />
<Compile Include="Helpers\ItemListDisplayHelpers\GroupedCollection.cs" />
<Compile Include="Helpers\ItemListDisplayHelpers\GroupingHelper.cs" />
Expand Down
5 changes: 3 additions & 2 deletions Files/Filesystem/FileTagsHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Common;
using Files.Filesystem.StorageItems;
using Files.Helpers;
using Files.Models.Settings;
using Microsoft.Toolkit.Uwp;
Expand Down Expand Up @@ -49,12 +50,12 @@ public static void WriteFileTag(string filePath, string tag)

public static async Task<ulong?> GetFileFRN(IStorageItem item)
{
if (item is StorageFolder folderItem)
if (item is BaseStorageFolder folderItem && folderItem.Properties != null)
{
var extraProperties = await folderItem.Properties.RetrievePropertiesAsync(new string[] { "System.FileFRN" });
return (ulong?)extraProperties["System.FileFRN"];
}
else if (item is StorageFile fileItem)
else if (item is BaseStorageFile fileItem && fileItem.Properties != null)
{
var extraProperties = await fileItem.Properties.RetrievePropertiesAsync(new string[] { "System.FileFRN" });
return (ulong?)extraProperties["System.FileFRN"];
Expand Down
Loading