summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimportd/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at/rhimportd/main.go')
-rw-r--r--src/helsinki.at/rhimportd/main.go46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/helsinki.at/rhimportd/main.go b/src/helsinki.at/rhimportd/main.go
index 362e8dc..8a212f9 100644
--- a/src/helsinki.at/rhimportd/main.go
+++ b/src/helsinki.at/rhimportd/main.go
@@ -27,13 +27,13 @@ package main
import (
"flag"
"fmt"
+ "helsinki.at/rhimport"
"log"
+ "net/http"
"os"
"os/signal"
"sync"
"time"
-
- "helsinki.at/rhimport"
// "io/ioutil"
)
@@ -86,15 +86,15 @@ func session_test(conf *rhimport.Config, rddb *rhimport.RdDbChan) {
ctx.ClearShowCarts = true
ctx.SourceUri = "http://www.tonycuffe.com/mp3/tail%20toddle.mp3"
- id, _, err := store.New(ctx)
- if err != nil {
- rhl.Printf("MAIN: Error SessionStore.New(): %s", err)
+ id, _, code, errstring := store.New(ctx)
+ if code != http.StatusOK {
+ rhl.Printf("MAIN: Error SessionStore.New(): %s", errstring)
return
}
var session *rhimport.SessionChan
- if session, err = store.Get(ctx.UserName, id); err != nil {
- rhl.Printf("MAIN: Error SessionStore.Get(): %s", err)
+ if session, code, errstring = store.Get(ctx.UserName, id); code != http.StatusOK {
+ rhl.Printf("MAIN: Error SessionStore.Get(): %s", errstring)
return
}
@@ -104,24 +104,24 @@ func session_test(conf *rhimport.Config, rddb *rhimport.RdDbChan) {
return
}
- // pch := make(chan string, 10)
- // if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress1); err != nil {
- // rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err)
- // }
- // go func() {
- // time.Sleep(3 * time.Second)
- // if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress2); err != nil {
- // rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err)
- // }
- // }()
+ pch := make(chan string, 10)
+ if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress1); err != nil {
+ rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err)
+ }
+ go func() {
+ time.Sleep(3 * time.Second)
+ if err = session.AddProgressHandler((chan<- string)(pch), session_test_progress2); err != nil {
+ rhl.Printf("MAIN: Error Session.AddProgressHandler(): %s", err)
+ }
+ }()
rhl.Printf("MAIN: calling run for %s/%s", ctx.UserName, id)
- session.Run(10 * time.Second)
+ session.Run(30 * time.Second)
for {
select {
- // case p := <-pch:
- // fmt.Println(p)
+ case p := <-pch:
+ fmt.Println(p)
case r := <-dch:
fmt.Printf("Import finished: %+v\n", r)
break
@@ -129,8 +129,8 @@ func session_test(conf *rhimport.Config, rddb *rhimport.RdDbChan) {
}
rhl.Printf("MAIN: calling remove for %s/%s", ctx.UserName, id)
- if err = store.Remove(ctx.UserName, id); err != nil {
- rhl.Printf("MAIN: Error SessionStore.Remove(): %s", err)
+ if code, errstring = store.Remove(ctx.UserName, id); code != http.StatusOK {
+ rhl.Printf("MAIN: Error SessionStore.Remove(): %s", errstring)
}
rhl.Printf("MAIN: remove done")
@@ -164,7 +164,7 @@ func main() {
}
defer rddb.Cleanup()
- // go session_test(conf, rddb.GetInterface())
+ go session_test(conf, rddb.GetInterface())
var wg sync.WaitGroup