From 945c2b499a3f67584acaa9e66bc2bea53f7071e5 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 26 Nov 2018 11:37:45 -0700 Subject: [PATCH] Fix date being null --- scripts/scan_torrents.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/scan_torrents.sh b/scripts/scan_torrents.sh index 06f26af..f3a6950 100755 --- a/scripts/scan_torrents.sh +++ b/scripts/scan_torrents.sh @@ -46,7 +46,12 @@ for torrent_file in *.torrent; do leechers=$(jq -r '.peers' <<< $health_text) completed=$(jq -r '.completed' <<< $health_text) date_string=$(jq -r '.created' <<< $health_text) - created_date=$(date -d "${date_string}" +"%s") + if [ -z $date_string ]; then + echo "Date was null, setting to now" + created_date=$(date +%s) + else + created_date=$(date -d "${date_string}" +"%s") + fi scraped_date=$(date +%s) # Construct add line