Ditto icon indicating copy to clipboard operation
Ditto copied to clipboard

Feature Request: New CLI flag for "Compact And Repair Database"

Open ronstudy1 opened this issue 3 years ago • 3 comments

I use to run a script that "Compact And Repair Database". I run it nightly when outside of work hours. Since this action is possible only though GUI then i have a script that opens ditto's "Advanced Options" and clicks on the suitable button. It could be great if this can be done through CLI instead

Thanks!

ronstudy1 avatar Mar 24 '21 22:03 ronstudy1

Any plans to support this feature?

ronstudy1 avatar May 27 '21 21:05 ronstudy1

Try vacuum the ditto.db with the sqlite3.exe binary avaiable from their website:

sqlite3.exe C:\My\Path\To\Ditto\Ditto.db "VACUUM;"

Better to shutdown Ditto before trying, just in case you have no .DB backups. Can be easily scripted with batch files and whatnot.

garoto avatar Jun 02 '21 22:06 garoto

Try vacuum the ditto.db with the sqlite3.exe binary avaiable from their website:

actually, the built-in Compact also deletes old entries before the "VACUUM;" command (code) so it's only a half-solution manually executing SQLs for deleting old entries is already too complicated. therefore i would really like to have Ditto support a new command line flag to compact the database

ronstudy1 avatar Feb 02 '22 16:02 ronstudy1

For those interested, here's the SQL command that can be used via the command line to compact the Ditto database:

sqlite3.exe C:\My\Path\To\Ditto\Ditto.db "DELETE FROM Main WHERE lID in (SELECT lID FROM Main WHERE (lastPasteDate < 1234) AND (bIsGroup = 0) AND (lShortCut = 0) AND (lParentID <= 0) AND (lDontAutoDelete = 0) AND (stickyClipOrder = -(2147483647)) AND (stickyClipGroupOrder = -(2147483647)));Delete FROM MainDeletes;VACUUM"

Notes:

  • replace 1234 with the desired epoch value for deleting entries that haven't been pasted before it (be assure that entries which are marked as "Never Auto Delete" would not be deleted anyway).
  • close ditto before running this command since "Ditto.db" shouldn't be used during the execution of this command

ronstudy1 avatar May 17 '23 03:05 ronstudy1