mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2020-11-18 19:53:40 -08:00
fixed issue with go-clamd
This commit is contained in:
parent
049d73ec21
commit
c53c3be577
@ -270,24 +270,22 @@ func scanHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
c := clamd.NewClamd(config.CLAMAV_DAEMON_HOST)
|
c := clamd.NewClamd(config.CLAMAV_DAEMON_HOST)
|
||||||
|
|
||||||
response, err := c.ScanStream(reader)
|
abort := make(chan bool)
|
||||||
|
response, err := c.ScanStream(reader, abort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("%s", err.Error())
|
log.Printf("%s", err.Error())
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var b string
|
select {
|
||||||
|
case s := <-response:
|
||||||
for s := range response {
|
w.Write([]byte(fmt.Sprintf("%v\n", s.Status)))
|
||||||
b += s
|
case <-time.After(time.Second * 60):
|
||||||
|
abort <- true
|
||||||
if !strings.HasPrefix(s, "stream: ") {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write([]byte(fmt.Sprintf("%v\n", s[8:])))
|
close(abort)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func putHandler(w http.ResponseWriter, r *http.Request) {
|
func putHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user