@@ -56,18 +56,29 @@ public async Task RestoreItemsAsync(IEnumerable<IStorableChild> items, IFolderPi
5656 if ( _specifics . Options . IsReadOnly )
5757 throw FileSystemExceptions . FileSystemReadOnly ;
5858
59- var allItems = items . Select ( x => x is IRecycleBinItem recycleBinItem ? recycleBinItem . AsWrapper < IStorable > ( ) . GetWrapperAt ( 1 ) . Inner : x ) . Cast < IStorableChild > ( ) . ToArray ( ) ;
60- switch ( allItems . Length )
59+ var allItems = items . ToArray ( ) ;
60+ var storableItems = allItems . Select ( x => x is IRecycleBinItem recycleBinItem ? recycleBinItem . AsWrapper < IStorable > ( ) . GetWrapperAt ( 1 ) . Inner : x ) . Cast < IStorableChild > ( ) . ToArray ( ) ;
61+ switch ( storableItems . Length )
6162 {
6263 case 1 :
6364 {
64- var item = allItems [ 0 ] ;
65+ var item = storableItems [ 0 ] ;
6566 var destinationFolder = await AbstractRecycleBinHelpers . GetDestinationFolderAsync (
6667 item ,
6768 _specifics ,
6869 StreamSerializer . Instance ,
6970 cancellationToken ) ;
7071
72+ if ( destinationFolder is null && allItems [ 0 ] is IRecycleBinItem recycleBinItem )
73+ {
74+ var originalParentPath = Path . GetDirectoryName ( recycleBinItem . Id ) ;
75+ if ( ! string . IsNullOrWhiteSpace ( originalParentPath ) )
76+ {
77+ destinationFolder = await SafetyHelpers . NoFailureAsync ( async ( ) =>
78+ await AbstractPathHelpers . GetCiphertextItemAsync ( originalParentPath , _specifics , cancellationToken ) as IModifiableFolder ) ;
79+ }
80+ }
81+
7182 // Prompt the user to pick the folder when the default destination couldn't be used
7283 destinationFolder ??= await GetDestinationFolderAsync ( ) ;
7384 if ( destinationFolder is null )
@@ -90,7 +101,7 @@ await AbstractRecycleBinHelpers.RestoreAsync(
90101 if ( destinationFolder is null )
91102 throw new InvalidOperationException ( "The destination folder couldn't be chosen." ) ;
92103
93- foreach ( var item in allItems )
104+ foreach ( var item in storableItems )
94105 {
95106 await AbstractRecycleBinHelpers . RestoreAsync (
96107 item ,
0 commit comments