[Cfapi: AckDelete] Got "Invalid File Handle" when deleting cloud file on Win10

Jojo Tang 86 Reputation points
2020-12-03T03:17:40.79+00:00

When working with the Cloud Filter API, user delete file via Explorer and our app got delete callback and execute QCF_OPERATION_TYPE_ACK_DELETE successfully. But Explorer show "Invalid File Handle" and file cannot be deleted.

44642-invalid-file-handle.png

We found that if PC install third party antivirus and delete file will get "Invalid File Handle". If tun on windows defender "Periodic scanning", file can be deleted successfully.
44612-enable-windows-defender.png

Please help to provide us suggestions (what registers or settings... app have to set up before delete cloud file??)
Thanks

Community Center Not monitored
{count} votes

2 answers

Sort by: Most helpful
  1. Jojo Tang 86 Reputation points
    2020-12-03T07:20:45.107+00:00

    Hi RitaHan,
    official sample Cloud Mirror does not register delete callback "CF_CALLBACK_TYPE_NOTIFY_DELETE"
    CF_CALLBACK_REGISTRATION FakeCloudProvider::s_MirrorCallbackTable[] =
    {
    { CF_CALLBACK_TYPE_FETCH_DATA, FakeCloudProvider::OnFetchData },
    { CF_CALLBACK_TYPE_CANCEL_FETCH_DATA, FakeCloudProvider::OnCancelFetchData },
    CF_CALLBACK_REGISTRATION_END
    };

    Our app registered as below:
    CF_CALLBACK_REGISTRATION FakeCloudProvider::s_MirrorCallbackTable[] =
    {
    { CF_CALLBACK_TYPE_FETCH_DATA, FakeCloudProvider::OnFetchData },
    { CF_CALLBACK_TYPE_VALIDATE_DATA, FakeCloudProvider::OnValidateData},
    { CF_CALLBACK_TYPE_CANCEL_FETCH_DATA, FakeCloudProvider::OnCancelFetchData },
    { CF_CALLBACK_TYPE_FETCH_PLACEHOLDERS, FakeCloudProvider::OnFetchPlaceholders},
    { CF_CALLBACK_TYPE_NOTIFY_FILE_OPEN_COMPLETION, FakeCloudProvider::OnFileOpenCompletion},
    { CF_CALLBACK_TYPE_NOTIFY_FILE_CLOSE_COMPLETION, FakeCloudProvider::OnFileCloseCompletion},
    { CF_CALLBACK_TYPE_NOTIFY_DEHYDRATE, FakeCloudProvider::OnDehydrate},
    { CF_CALLBACK_TYPE_NOTIFY_DEHYDRATE_COMPLETION, FakeCloudProvider::OnDehydrateCompletion},
    { CF_CALLBACK_TYPE_NOTIFY_DELETE, FakeCloudProvider::OnDelete},
    { CF_CALLBACK_TYPE_NOTIFY_DELETE_COMPLETION, FakeCloudProvider::OnDeleteCompletion},
    { CF_CALLBACK_TYPE_NOTIFY_RENAME, FakeCloudProvider::OnRename},
    { CF_CALLBACK_TYPE_NOTIFY_RENAME_COMPLETION, FakeCloudProvider::OnRenameCompletion},
    CF_CALLBACK_REGISTRATION_END
    };

    if remove "CF_CALLBACK_TYPE_NOTIFY_DELETE" and "CF_CALLBACK_TYPE_NOTIFY_DELETE_COMPLETION", file can be deleted successfully.
    But why these two callback implemented result in delete cloud file failed??


  2. Jojo Tang 86 Reputation points
    2020-12-03T08:34:09.607+00:00

    Hi RitaHan,
    void OnDelete(const QCF_CALLBACK_INFO * callbackInfo, const QCF_CALLBACK_PARAMETERS * callbackParameters)
    {
    HRESULT hr = E_FAIL;

    CF_OPERATION_INFO opInfo = { 0 };
    CF_OPERATION_PARAMETERS opParams = { 0 };
    
    opInfo.StructSize = sizeof(opInfo);
    opInfo.Type = CF_OPERATION_TYPE_ACK_DELETE;
    opInfo.ConnectionKey = callbackInfo->ConnectionKey;
    opInfo.TransferKey = callbackInfo->TransferKey;
    
    opParams.ParamSize = CF_SIZE_OF_OP_PARAM(AckDelete);
    opParams.AckDelete.CompletionStatus = NTSTATUS_FROM_WIN32(ERROR_SUCCESS);
    opParams.AckDelete.Flags = CF_OPERATION_ACK_DELETE_FLAG_NONE;
    
    hr = CfExecute(&opInfo, &opParams);
    

    }

    void OnDeleteCompletion(const QCF_CALLBACK_INFO * callbackInfo, const QCF_CALLBACK_PARAMETERS * callbackParameters)
    {

    }


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.