On Windows:
Don't replace %AppData%\calibre\ when calibre, or the server, the viewer, the book editor, any command line tools etc are running.
Same goes for editing, adding, or deleting any files or folders in %AppData%\calibre\, with the added precaution of taking a copy of it before making any changes.
I do not know if the same precautions are needed on MacOX or Linux.
BR