Commands : RenameAsync
RenameAsync is used to change the file name.
Task RenameAsync(string currentName, string newName, Etag etag = null);
|currentName||string||The name of the file that you want to change|
|newName||string||The new name of a file|
|etag||Etag||The current file etag used for concurrency checks (
|Task||A task that represents the asynchronous rename operation|
await store .AsyncFilesCommands .RenameAsync( "/movies/intro.avi", "/movies/introduction.avi" );
Note that a file move operation is basically the rename too (directories are just a virtual concept). In order to move
intro.avi file from
/movies folder to
/movies/examples, we need to use the following code:
await store .AsyncFilesCommands .RenameAsync( "/movies/intro.avi", "/movies/examples/intro.avi" );
Rename on the server side
If the file rename is requested, RavenFS needs to update collection of usages of this file's pages. In order to make RavenFS resistant to restarts in the middle of the rename operation, use a a periodic task, which ensures that all requested renames will be finished after the restart.