Add storage API abstraction

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-06-22 09:16:49 -03:00
committed by Marcos Lilljedahl
19 changed files with 277 additions and 83 deletions

View File

@@ -32,7 +32,7 @@ func Bootstrap() {
s, err := storage.NewFileStorage(config.SessionsFile)
if err != nil && !os.IsNotExist(err) {
log.Fatal("Error decoding sessions from disk ", err)
log.Fatal("Error initializing StorageAPI: ", err)
}
core = pwd.NewPWD(d, t, Broadcast, s)

View File

@@ -1,6 +1,7 @@
package handlers
import (
"io"
"log"
"net/http"
@@ -28,18 +29,34 @@ func FileUpload(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(http.StatusOK)
return
} else {
// This is for multipart upload
log.Println("Not implemented yet")
/*
err := req.ParseMultipartForm(32 << 20)
red, err := req.MultipartReader()
if err != nil {
log.Println(err)
rw.WriteHeader(http.StatusBadRequest)
return
}
for {
p, err := red.NextPart()
if err == io.EOF {
break
}
if err != nil {
log.Println(err)
rw.WriteHeader(http.StatusBadRequest)
continue
}
if p.FileName() == "" {
continue
}
err = core.InstanceUploadFromReader(i, p.FileName(), p)
if err != nil {
log.Println(err)
rw.WriteHeader(http.StatusInternalServerError)
return
}
*/
rw.WriteHeader(http.StatusInternalServerError)
log.Printf("Uploaded [%s] to [%s]\n", p.FileName(), i.Name)
}
rw.WriteHeader(http.StatusOK)
return
}

View File

@@ -34,8 +34,7 @@ func WS(so socketio.Socket) {
so.On("terminal in", func(name, data string) {
// User wrote something on the terminal. Need to write it to the instance terminal
instance := core.InstanceGet(session, name)
core.InstanceWriteToTerminal(instance, data)
core.InstanceWriteToTerminal(session.Id, name, data)
})
so.On("viewport resize", func(cols, rows uint) {