Search code examples
winapifilesystemsvirtualfilesystemvirtual-drive

Rename folder with overwrite deletes the source folder in Cloud Files API


I am creating a virtual file system using Cloud Files API. I am trying to implement rename/move and delete operations for folders. The rename folder with overwrite scenario (when the target folder exists) behavior is confusing. In Windows Explored I am trying to rename Z:\Folder1 to Z:\Folder2 while the Z:\Folder2 already exists. Before the the rename operation is performed, the source folder is being deleted by calling CF_CALLBACK_TYPE_NOTIFY_DELETE callback.

Here is the sequence of callbacks that I get with Cloud Filter API:

  1. CF_CALLBACK_TYPE_NOTIFY_DELETE is called on the source folder.
  2. Each file from source folder is being moved to the target folder.
  3. CF_CALLBACK_TYPE_NOTIFY_DELETE_COMPLETION is called on the source folder.

As a result there is no way to delete a folder in my storage inside the CF_CALLBACK_TYPE_NOTIFY_DELETE callback because this will delete all files prior to the move operation. Also there is no way to distinguish between delete and move operations inside the CF_CALLBACK_TYPE_NOTIFY_DELETE (so I can ignore it for the move operation).

How do I properly implement the delete and rename/move callbacks in Cloud Files API?


Solution

  • It is specific of Windows File Manager. I tried "Move" operation using PowerShell "Move-Item" with "-Force" option and I got next sequence of callbacks (without delete callbacks):

    1. CF_CALLBACK_TYPE_NOTIFY_RENAME
    2. CF_CALLBACK_TYPE_NOTIFY_RENAME_COMPLETION