summaryrefslogtreecommitdiffstats
path: root/clerk
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-02-14 13:56:21 +0100
committerRasmus Steinke <rasi@xssn.at>2017-02-14 13:56:21 +0100
commit4bc98a37859c75be05e96e70da73c21eb22837a7 (patch)
treebac2c2bc21b19044cb8e1339bc202e518e20bdaa /clerk
parentb7b9b4a8371993475d1e0851994ba14f18b4e05c (diff)
downloadperl-app-clerk-4bc98a37859c75be05e96e70da73c21eb22837a7.tar.gz
perl-app-clerk-4bc98a37859c75be05e96e70da73c21eb22837a7.tar.xz
only perform backup once an hour
Diffstat (limited to 'clerk')
-rwxr-xr-xclerk15
1 files changed, 12 insertions, 3 deletions
diff --git a/clerk b/clerk
index dc62967..f83d78b 100755
--- a/clerk
+++ b/clerk
@@ -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