Sync DB to disk after optimize & safely rename
Don't overwrite an existing file if the data transfer failed
Merge pull request #3 from Incubaid/safe-optimize

Make `tcbdboptimizeimpl` more safe