How can I customize the plugin to overwrite files in the assets/ directory?

Hello everyone, I am developing a plugin that automatically optimizes the image size when pasting images. It is implemented based on sharp.

I initially thought I could run Node directly in the desktop version of Logseq, but I found that it is not possible. A client-server architecture is required.

Currently, I have completed the server-side part: https://github.com/scarletsky/sharp-server

The client-side part is also partially completed: https://github.com/scarletsky/logseq-plugin-sharp

Currently, one tricky issue: I want the optimized image to automatically overwrite the original file when the user selects it, otherwise, there will be two copies of the file in the assets/ directory.
However, I haven’t found a solution to this problem (which is also mentioned in my logseq-plugin-sharp plugin).

Is there a solution to this issue?