git ssb

0+

cel / ggscrape



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

ggscrapechanged
ggscrapeView
@@ -37,11 +37,15 @@
3737 req_fragment() {
3838 req "?_escaped_fragment_=$@"
3939 }
4040
41-test_permission() {
41 +check_permission() {
4242 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
4448 }
4549
4650 get_topics_single() {
4751 local start=$1
@@ -73,8 +77,10 @@
7377 if ((start==0)); then
7478 start=1
7579 fi
7680
81 + check_permission || return 1
82 +
7783 debug_print "get all topics $group_id [$start-$end]"
7884
7985 for ((i = start; i <= end || end == 0; i += topic_range)); do
8086 ((temp_end = (end && i+topic_range-1 > end) ? end : i+topic_range-1))
@@ -137,9 +143,9 @@
137143 cat << EOF
138144 ggscrape. Download emails from a Google Group
139145
140146 Usage:
141- ggscrape <group_id> [test]
147 + ggscrape <group_id> test
142148 ggscrape <group_id> topics
143149 ggscrape <group_id> messages <topic_id>
144150 ggscrape <group_id> download <dest_dir>
145151
@@ -192,9 +198,9 @@
192198 fi
193199
194200 case "$cmd" in
195201 '') show_help; exit;;
196- test) test_permission;;
202 + test) check_permission && echo Success;;
197203 topics) get_topics "$topic_begin" "$topic_end";;
198204 download) download_mails "$topic_begin" "$topic_end";;
199205 messages) get_messages "$topic_id";;
200206 *) echo "Unknown command $cmd" >&2;;

Built with git-ssb-web