Commit a16d12d2293f1d8d8d6a7e70ef27dae8a8c0e71f
Make test command more sensible.
Check permissions when getting topics or downloading mail.Charles Lehner committed on 9/12/2014, 6:42:33 PM
Parent: 290cb56949f573b3a963bd0d00820e6c756f3704
Files changed
ggscrape | changed |
ggscrape | |||
---|---|---|---|
@@ -37,11 +37,15 @@ | |||
37 | 37 … | req_fragment() { | |
38 | 38 … | req "?_escaped_fragment_=$@" | |
39 | 39 … | } | |
40 | 40 … | ||
41 | -test_permission() { | ||
41 … | +check_permission() { | ||
42 | 42 … | debug_print testing permission | |
43 | - req_fragment "forum/${group_id}%5B1-1-false%5D" -I | grep -q '200 OK' | ||
43 … | + if ! req_fragment "forum/${group_id}%5B1-1-false%5D" -I | grep -q '200 OK' | ||
44 … | + then | ||
45 … | + echo 'Unable to access group.' >&2 | ||
46 … | + return 1 | ||
47 … | + fi | ||
44 | 48 … | } | |
45 | 49 … | ||
46 | 50 … | get_topics_single() { | |
47 | 51 … | local start=$1 | |
@@ -73,8 +77,10 @@ | |||
73 | 77 … | if ((start==0)); then | |
74 | 78 … | start=1 | |
75 | 79 … | fi | |
76 | 80 … | ||
81 … | + check_permission || return 1 | ||
82 … | + | ||
77 | 83 … | debug_print "get all topics $group_id [$start-$end]" | |
78 | 84 … | ||
79 | 85 … | for ((i = start; i <= end || end == 0; i += topic_range)); do | |
80 | 86 … | ((temp_end = (end && i+topic_range-1 > end) ? end : i+topic_range-1)) | |
@@ -137,9 +143,9 @@ | |||
137 | 143 … | cat << EOF | |
138 | 144 … | ggscrape. Download emails from a Google Group | |
139 | 145 … | ||
140 | 146 … | Usage: | |
141 | - ggscrape <group_id> [test] | ||
147 … | + ggscrape <group_id> test | ||
142 | 148 … | ggscrape <group_id> topics | |
143 | 149 … | ggscrape <group_id> messages <topic_id> | |
144 | 150 … | ggscrape <group_id> download <dest_dir> | |
145 | 151 … | ||
@@ -192,9 +198,9 @@ | |||
192 | 198 … | fi | |
193 | 199 … | ||
194 | 200 … | case "$cmd" in | |
195 | 201 … | '') show_help; exit;; | |
196 | - test) test_permission;; | ||
202 … | + test) check_permission && echo Success;; | ||
197 | 203 … | topics) get_topics "$topic_begin" "$topic_end";; | |
198 | 204 … | download) download_mails "$topic_begin" "$topic_end";; | |
199 | 205 … | messages) get_messages "$topic_id";; | |
200 | 206 … | *) echo "Unknown command $cmd" >&2;; |
Built with git-ssb-web