I’m working on a plugin that should copy several files from the plugin folder to the user-selected folder.
The problem is that I get this error:
Plugin Error: copyEntry: failed to copy file
at Object._copyFileEntry (uxp://uxp-internal/webfs_scripts.js:2:66158)
But… the file is actually copied to the selected location. The problem is that since the error is thrown the plugin doesn’t execute the code that comes after the file copy.
Sorry, but just not awaiting it isn’t really a good solution for this (to clarify: I’m not saying the answer is bad; it just might get interpreted in a way that leads to bad practices ). While it might make this work, it causes more harm than good. If a promise like this rejects, this should get handled by the plugin in some way (error message, …). Simply not awaiting the result of the operation is basically like throwing away information.
The curious thing here, of course, is that
Therefore, there seems to be a discrepancy between the result of the Promise (rejection) and what actually happens in the file system (success). To me, it kind of sounds like some file permission issues, but that is up to Adobe to figure out (since this seems to be something that fails internally inside the copyTo function).
If you really want to “throw away” the information the promise gives you, for now (since the result of the promise appears to give you wrong information), wrap the relevant code into a trycatch block and handle this error case (which might be an actual error!) inside the catch block (if this is non-critical, you can, of course, ignore the error case, that’s up to you, @piotrD ).
I’m re-categorizing this to API Feedback/Bugs as the error message appearing while the file successfully gets copied clearly means there’s some sort of bug (maybe an edge-case, but still) inside uxp.storage.Entry::copyTo…