@@ -26,6 +26,9 @@ namespace Files.App.Helpers
26
26
{
27
27
public class FileOperationsHelpers
28
28
{
29
+ private static readonly Ole32 . PROPERTYKEY PKEY_FilePlaceholderStatus = new Ole32 . PROPERTYKEY ( new Guid ( "B2F9B9D6-FEC4-4DD5-94D7-8957488C807B" ) , 2 ) ;
30
+ private const uint PS_CLOUDFILE_PLACEHOLDER = 8 ;
31
+
29
32
private static ProgressHandler ? progressHandler ; // Warning: must be initialized from a MTA thread
30
33
31
34
public static Task SetClipboard ( string [ ] filesToCopy , DataPackageOperation operation )
@@ -119,14 +122,29 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera
119
122
op . Options |= ShellFileOperations . OperationFlags . RecycleOnDelete ;
120
123
121
124
var shellOperationResult = new ShellOperationResult ( ) ;
125
+ var tryDelete = false ;
122
126
123
127
for ( var i = 0 ; i < fileToDeletePath . Length ; i ++ )
124
128
{
125
129
if ( ! SafetyExtensions . IgnoreExceptions ( ( ) =>
126
130
{
127
131
using var shi = new ShellItem ( fileToDeletePath [ i ] ) ;
128
132
var file = SafetyExtensions . IgnoreExceptions ( ( ) => GetFirstFile ( shi ) ) ?? shi ;
129
- op . QueueDeleteOperation ( file ) ;
133
+ if ( file . Properties . GetProperty < uint > ( PKEY_FilePlaceholderStatus ) == PS_CLOUDFILE_PLACEHOLDER )
134
+ {
135
+ // Online only files cannot be tried for deletion, so they are treated as to be permanently deleted.
136
+ shellOperationResult . Items . Add ( new ShellOperationItemResult ( )
137
+ {
138
+ Succeeded = false ,
139
+ Source = fileToDeletePath [ i ] ,
140
+ HResult = HRESULT . COPYENGINE_E_RECYCLE_BIN_NOT_FOUND
141
+ } ) ;
142
+ }
143
+ else
144
+ {
145
+ op . QueueDeleteOperation ( file ) ;
146
+ tryDelete = true ;
147
+ }
130
148
} ) )
131
149
{
132
150
shellOperationResult . Items . Add ( new ShellOperationItemResult ( )
@@ -138,6 +156,9 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera
138
156
}
139
157
}
140
158
159
+ if ( ! tryDelete )
160
+ return ( true , shellOperationResult ) ;
161
+
141
162
var deleteTcs = new TaskCompletionSource < bool > ( ) ;
142
163
op . PreDeleteItem += [ DebuggerHidden ] ( s , e ) =>
143
164
{
0 commit comments