aaApi_ChangeDocumentFile

One of our tools to migrate into ProjectWise from other document management systems has started having an intermittent issue that I cannot figure out.  To add multiple versions of a document, we fetch all of the versions into a staging area with the version number appended to the filename so they're all unique, and then loop through all of the versions (e.g. Versions of "A.docx" will have "A_1.0.docx", "A_1.1.docx", etc.)  The first version is created with aaApi_CreateDocument.  Subsequent versions get the new version added using aaApi_ChangeDocumentVersion, which creates the new version and attaches the previous version's file to it.  The file is then updated with aaApi_ChangeDocumentFile, specifying the folder and the latest version's document ID, and the local file (e.g. "c:\temp\A_1.1.docx").

This has worked for years with no issues.  Recently, it will sporadically fail on some files.  It doesn't happen often, but fails on certain files consistently.  The error message is "Error 58028: Error changing document file.
The file name is already used in this folder. Change the file name and try again."

I can get around the issue by renaming the file in the staging area ("A_1.1.docx" becomes "A_1.1.docxA") and reprocessing it.  So far, that has not failed to fix the issue.  But I don't understand why it is necessary.

Any insight would be appreciated.