Skip to content

Commit d64042b

Browse files
committed
Fix shortucts sometimes not copied
1 parent e4e12aa commit d64042b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Files/Helpers/UIFilesystemHelpers.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public static async void CutItem(IShellPage associatedInstance)
2828
RequestedOperation = DataPackageOperation.Move
2929
};
3030
ConcurrentBag<IStorageItem> items = new ConcurrentBag<IStorageItem>();
31-
FilesystemResult result = (FilesystemResult)false;
3231

3332
var canFlush = true;
3433
if (associatedInstance.SlimContentPage.IsItemSelected)
@@ -61,27 +60,27 @@ await Task.WhenAll(associatedInstance.SlimContentPage.SelectedItems.ToList().Sel
6160
}
6261
else if (listedItem.PrimaryItemAttribute == StorageItemTypes.File || listedItem is ZipItem)
6362
{
64-
result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath)
63+
var result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath)
6564
.OnSuccess(t => items.Add(t));
6665
if (!result)
6766
{
68-
throw new IOException($"Failed to process {listedItem.ItemPath}.");
67+
throw new IOException($"Failed to process {listedItem.ItemPath}.", (int)result.ErrorCode);
6968
}
7069
}
7170
else
7271
{
73-
result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
72+
var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
7473
.OnSuccess(t => items.Add(t));
7574
if (!result)
7675
{
77-
throw new IOException($"Failed to process {listedItem.ItemPath}.");
76+
throw new IOException($"Failed to process {listedItem.ItemPath}.", (int)result.ErrorCode);
7877
}
7978
}
8079
}));
8180
}
82-
catch
81+
catch (Exception ex)
8382
{
84-
if (result.ErrorCode == FileSystemStatusCode.Unauthorized)
83+
if (ex.HResult == (int)FileSystemStatusCode.Unauthorized)
8584
{
8685
// Try again with fulltrust process
8786
var connection = await AppServiceConnectionHelper.Instance;
@@ -139,7 +138,6 @@ public static async Task CopyItem(IShellPage associatedInstance)
139138
ConcurrentBag<IStorageItem> items = new ConcurrentBag<IStorageItem>();
140139

141140
string copySourcePath = associatedInstance.FilesystemViewModel.WorkingDirectory;
142-
FilesystemResult result = (FilesystemResult)false;
143141

144142
var canFlush = true;
145143
if (associatedInstance.SlimContentPage.IsItemSelected)
@@ -162,27 +160,27 @@ await Task.WhenAll(associatedInstance.SlimContentPage.SelectedItems.ToList().Sel
162160
}
163161
else if (listedItem.PrimaryItemAttribute == StorageItemTypes.File || listedItem is ZipItem)
164162
{
165-
result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath)
163+
var result = await associatedInstance.FilesystemViewModel.GetFileFromPathAsync(listedItem.ItemPath)
166164
.OnSuccess(t => items.Add(t));
167165
if (!result)
168166
{
169-
throw new IOException($"Failed to process {listedItem.ItemPath}.");
167+
throw new IOException($"Failed to process {listedItem.ItemPath}.", (int)result.ErrorCode);
170168
}
171169
}
172170
else
173171
{
174-
result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
172+
var result = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(listedItem.ItemPath)
175173
.OnSuccess(t => items.Add(t));
176174
if (!result)
177175
{
178-
throw new IOException($"Failed to process {listedItem.ItemPath}.");
176+
throw new IOException($"Failed to process {listedItem.ItemPath}.", (int)result.ErrorCode);
179177
}
180178
}
181179
}));
182180
}
183-
catch
181+
catch (Exception ex)
184182
{
185-
if (result.ErrorCode == FileSystemStatusCode.Unauthorized)
183+
if (ex.HResult == (int)FileSystemStatusCode.Unauthorized)
186184
{
187185
// Try again with fulltrust process
188186
var connection = await AppServiceConnectionHelper.Instance;

0 commit comments

Comments
 (0)