diff options
author | Rasmus Steinke <rasi@xssn.at> | 2017-02-14 13:56:21 +0100 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2017-02-14 13:56:21 +0100 |
commit | 4bc98a37859c75be05e96e70da73c21eb22837a7 (patch) | |
tree | bac2c2bc21b19044cb8e1339bc202e518e20bdaa /clerk | |
parent | b7b9b4a8371993475d1e0851994ba14f18b4e05c (diff) | |
download | perl-app-clerk-4bc98a37859c75be05e96e70da73c21eb22837a7.tar.gz perl-app-clerk-4bc98a37859c75be05e96e70da73c21eb22837a7.tar.xz |
only perform backup once an hour
Diffstat (limited to 'clerk')
-rwxr-xr-x | clerk | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -1210,10 +1210,19 @@ rateTrack () { notify-send "clerk" "rated ${rateartist} - ${ratetitle} with $(echo ${rating})" fi if [[ $auto_track_rating_backup == "true" ]]; then - rm -f $HOME/.config/clerk/trackratings.json - clerk_helper importtrackratings + if [[ -f $HOME/.config/clerk/.last_trackratings_backup ]]; then + read -r lastbackup<$HOME/.config/clerk/.last_trackratings_backup + else + lastbackup=$(date "+%s") + fi + if [[ $(date "+%s") -gt $(( $lastbackup + 3600)) ]]; then + rm -f $HOME/.config/clerk/trackratings.json + clerk_helper importtrackratings + rm -f $HOME/.config/clerk/.last_trackratings_backup + fi + date "+%s" > $HOME/.config/clerk/.last_trackratings_backup fi - fi + fi } # function to instantly rate a track without a submenu. rating is defined on |