Move File-activity does not wait until file has been moved

Apparently Move File-activity does not wait for files to be moved to destination folder before it continues to the next activity. This has caused occasional crashes for my robot.

My process moves a file from temp-folder to the final destination as the last action of Process.xaml and then as the first action after getting the next transaction in Main.xaml it first searches the temp-folder for any files and then deletes them one by one. Occasionally I noticed that the file was still present in the temp-folder when the activity searched for files in the folder, but when it started deleting the files the transfer was completed and Delete File crashed due to file not found or access denied.

I tested it with a simple Move File-activity and a message box as the next activity. Message box is always displayed before the file appears in the destination folder.

I would imagine the activity should have a built-in check for if the move was completed? Instead we now have to put a loop that checks if the destination path exists before continuing the process.

Has anyone experienced similar issues with other activities that continue the process even if the task has not yet been completed?

I have experienced this as well. Before letting your process continue, you can write a loop to wait for the path to be fully moved. However, I do think that the Delete File activity should not continue until the move is complete or have an option to choose what it does.

2 Likes

Hi

I’ve just experienced this with a Delete Folder activity.

My context is that a \Temp folder is deleted at the start of a process before re-creating it. The \Temp folder contains 6 files, one of which is about 23mb. The folder is on a local file server.

On one occasion (only one so far after 10s of runs) the Temp folder is deleted but not re-created. No exceptions are thrown.

I believe that what is happening is:

  1. the Delete Folder step does not complete before the Create Folder activity starts
  2. the Create Folder activity does not attempt to create the folder as it already exists.

Another explanation could be the way in which MS server handles the requests. It releases the job to delete the folder before the deletion has completed, as this speeds it up. The lower level file io is then queued in a buffer. I’ve see AS/400 disk systems behave like this. The Create folder job is submitted in parallel and as this completes before the folder has been deleted (the queued job in the buffer is still running, deleting the files in the folder).

Then, either:
(a) because the folder s the folder exists, it ignores the request to create the folder, or
(b) the OS believes the folder does not exist (as per its file catalog, updated when the Delete Folder request was cached) so creates it. When the Delete Folder process completes, it deletes the folder just created.

Or something like that.

In any case, it’s no doubt because of the rapidity in which UiPath can interact with the OS, many times faster than the user would respond while interacting with the file Explorer window. I suspect that it’s a flaw in the UiPath path activity as it should confirm that the folder has been deleted, in the same way that Explorer would refresh to show the user that the folder no longer exists.

To solve this, I have a WaitFileExists function I can amend to both wait for a Folder to exist and for a file/folder also not to exist (simple retry scope)

I agree with both the above responses. It’s why it’s key to ensure you’ve got pre and post conditions built for activities like this.

IE you build the activity into a component wraparound; in the example of copying a file, you action the copy file activity, then have a post condition looping round, checking the file exists, and only proceeding when it’s fully there (NB you may need a bit more intelligence here in the case of larger files whereby it “exists”, but the copy operation is still processing the file).

For moving a file, it is a bit easier; you have two post conditions, one to check if the original filepath doesn’t exist, after which, you also check the new file path does exist.

Another thing to note, make sure there’s always a maximum number of loops - its easy to forget, these activities do occasionally have a hitch, and for example it’ll copy but not delete the original file, meaning it’ll loop endlessly :smile:

1 Like