I would propose a much simpler way to avoid this kind of issue: remove the "Delete Library" command.
Apparently (I never tried the command; I did not even notice it existed) all it does is to wipe the folder and all sub-folders.
On most systems, there is an OS command to do that....