Skip to content
Gerald Jansen edited this page Jun 23, 2023 · 19 revisions

Troubleshooting

Make sure there is no mismatch between the running services and the launched hamster: remember to kill the hamster daemons when version changes.

Make sure there are no remnants of a previous installation (see below)

Uninstall

If the installation was done through the distribution package manager, just use it again.

To undo the last install done with waf, just

sudo ./waf uninstall

Otherwise, need to find out which files have been installed. This can be tricky, as one should remember the exact version (commit sha or tag) and which options have been passed (usually none).
At some point the --prefix=/usr was recommended, and there are often unwanted installs with --prefix=/usr/local.
Available tags can be listed by git tag.

git checkout <commit sha or tag>
./waf configure <options>
sudo ./waf uninstall

Afterwards find /usr -iname hamster should only list unrelated files (if any). Note the case-insensitive search iname because to comply with freedesktop specifications some files are camel-cased now.

Known unrelated files

This project never installed anything under /usr/share/vim/, the files under this directory are unrelated.
/usr/share/vim/vim80/syntax/hamster.vim is reassuring:

Description: Hamster Classic Hamster is a local server for news and mail. It's a windows-32-bit-program.

Merging two hamster.db files

See https://github.com/projecthamster/hamster/issues/340#issuecomment-324387786

You may also like to try htool from https://github.com/GeraldJansen/hamster-tool/.

Creating a dummy hamster.db for demo/testing

Original request here. Taking advantage of the fact that the hamster DB can be swapped "live", you can easily create one as follows:

# make a backup copy of your current DB 
DBDIR=~/.local/share/hamster # or hamster-applet for older versions
cp $DBDIR/hamster.db ~/bu-hamster.db

# download empty template hamster.db and replace your live DB
wget https://github.com/projecthamster/hamster/tree/master/data/hamster.db
mv hamster.db $DBDIR

# add activities, test, etc.

# save the dummy DB and restore your backup copy
cp $DBDIR/hamster.db ~/dummy-hamster.db
cp ~/bu-hamster.db $DBDIR

Of course, to do more testing/demonstration, you'd need to put the dummy-hamster.db back as $DBDIR/hamster.db, which is a real bother. You could automate this with scripts, softlinks etc.. However, it would probably be best to have a separate environment for testing/demo, say a dedicated userid or a separate virtual environment.

To automate the creation of test cases with recent dates, one can create -nnn/+nnn relative timestamps in a bash script, as in the following example:

# function for relative timestamp (arg -nnn or +nnn minutes)
function rts() { echo $(date +%Y-%m-%d\ %H:%M -d"$1 minutes"); }
# test of embedded activities 
hamster track 'outer activity@test, testing embedded activies #dev' $(rts -60) $(rts -10)
hamster track 'inner activity@test #dev' $(rts -60) $(rts -30)
hamster track 'test@ABC/Cooker' $(rts +0) $(rts +30)
...

Pruning old and unused data

Backup your active hamster.db file and kill hamster daemons as described in the README. Enter the SQL statements below one by one, using sqlite3 $DBDIR/hamster.db or sqlitebrowser $DBDIR/hamster.db, where DBDIR=~/.local/share/hamster/hamster.db for example.

select count(*) from facts where start_time < '2020-01-01';
delete from facts where start_time < '2020-01-01';

select count(*) from fact_tags where fact_id not in (select id from facts);
delete from fact_tags where fact_id not in (select id from facts);

delete from tags where id not in (select tag_id from fact_tags);

select count(*) from activities where id not in (select distinct activity_id from facts);
delete from activities where id not in (select distinct activity_id from facts);

select count(*) from categories where id not in (select distinct category_id from activities);
delete from categories where id not in (select distinct category_id from activities);

Finding old unterminated activities

Thanks to @aquaherd (https://github.com/projecthamster/hamster/issues/689#issuecomment-1604571930):

Finding open ended or uncategorized facts is as easy as:

hamster list 2013-01-01 2024-01-01 | grep '| '