mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-27 18:53:20 +01:00
release (fix): fix issues before release
This commit is contained in:
parent
a1cb4e146e
commit
ce21121dce
7 changed files with 30 additions and 28 deletions
|
|
@ -79,8 +79,10 @@ steps:
|
|||
- ./dist/filestash &
|
||||
- cd ../test/e2e
|
||||
- npm install > /dev/null 2>&1
|
||||
- node servers/webdav.js &
|
||||
- npm test
|
||||
- kill -9 %1
|
||||
- kill -9 %2
|
||||
|
||||
- name: release
|
||||
image: plugins/docker
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export class SetupPage extends React.Component {
|
|||
this.setState({enable_telemetry: config.log.telemetry.value}, () => {
|
||||
if(this.state.enable_telemetry === true) return;
|
||||
this.unlisten = this.props.history.listen((location, action) => {
|
||||
this.unlisten();
|
||||
alert.now((
|
||||
<div>
|
||||
<p style={{textAlign: 'justify'}}>
|
||||
|
|
@ -37,7 +38,7 @@ export class SetupPage extends React.Component {
|
|||
</label>
|
||||
</form>
|
||||
</div>
|
||||
), () => this.unlisten());
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ RUN mkdir -p $GOPATH/src/github.com/mickael-kerjean/ && \
|
|||
#################
|
||||
# Create machine user
|
||||
addgroup -S filestash && adduser -S -g filestash filestash && \
|
||||
chown -R filestash:filestash /app/
|
||||
chown -R filestash:filestash /app/ && \
|
||||
chown filestash:filestash /app/data/config/config.json
|
||||
|
||||
EXPOSE 8334
|
||||
VOLUME ["/app/data/config/"]
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ func Init(a *App) {
|
|||
session.HandleFunc("", NewMiddlewareChain(SessionGet, middlewares, *a)).Methods("GET")
|
||||
middlewares = []Middleware{ ApiHeaders, SecureHeaders, BodyParser }
|
||||
session.HandleFunc("", NewMiddlewareChain(SessionAuthenticate, middlewares, *a)).Methods("POST")
|
||||
middlewares = []Middleware{ ApiHeaders, SecureHeaders }
|
||||
middlewares = []Middleware{ ApiHeaders, SecureHeaders, SessionTry }
|
||||
session.HandleFunc("", NewMiddlewareChain(SessionLogout, middlewares, *a)).Methods("DELETE")
|
||||
middlewares = []Middleware{ ApiHeaders, SecureHeaders }
|
||||
session.HandleFunc("/auth/{service}", NewMiddlewareChain(SessionOAuthBackend, middlewares, *a)).Methods("GET")
|
||||
|
||||
// API for admin
|
||||
|
|
|
|||
|
|
@ -48,10 +48,6 @@ func AdminOnly(fn func(App, http.ResponseWriter, *http.Request)) func(ctx App, r
|
|||
}
|
||||
|
||||
func SessionStart (fn func(App, http.ResponseWriter, *http.Request)) func(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
extractBackend := func(req *http.Request, ctx *App) (IBackend, error) {
|
||||
return model.NewBackend(ctx, ctx.Session)
|
||||
}
|
||||
|
||||
return func(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
var err error
|
||||
if ctx.Share, err = _extractShare(req); err != nil {
|
||||
|
|
@ -62,7 +58,7 @@ func SessionStart (fn func(App, http.ResponseWriter, *http.Request)) func(ctx Ap
|
|||
SendErrorResult(res, err)
|
||||
return
|
||||
}
|
||||
if ctx.Backend, err = extractBackend(req, &ctx); err != nil {
|
||||
if ctx.Backend, err = _extractBackend(req, &ctx); err != nil {
|
||||
SendErrorResult(res, err)
|
||||
return
|
||||
}
|
||||
|
|
@ -70,6 +66,15 @@ func SessionStart (fn func(App, http.ResponseWriter, *http.Request)) func(ctx Ap
|
|||
}
|
||||
}
|
||||
|
||||
func SessionTry (fn func(App, http.ResponseWriter, *http.Request)) func(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
return func(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
ctx.Share, _ = _extractShare(req)
|
||||
ctx.Session, _ = _extractSession(req, &ctx)
|
||||
ctx.Backend, _ = _extractBackend(req, &ctx)
|
||||
fn(ctx, res, req)
|
||||
}
|
||||
}
|
||||
|
||||
func RedirectSharedLoginIfNeeded(fn func(App, http.ResponseWriter, *http.Request)) func(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
return func(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
share_id := _extractShareId(req)
|
||||
|
|
@ -227,3 +232,7 @@ func _extractSession(req *http.Request, ctx *App) (map[string]string, error) {
|
|||
return session, err
|
||||
}
|
||||
}
|
||||
|
||||
func _extractBackend(req *http.Request, ctx *App) (IBackend, error) {
|
||||
return model.NewBackend(ctx, ctx.Session)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "github.com/mickael-kerjean/filestash/server/common"
|
||||
"github.com/secsy/goftp"
|
||||
"io"
|
||||
|
|
@ -28,8 +29,7 @@ type Ftp struct {
|
|||
}
|
||||
|
||||
func (f Ftp) Init(params map[string]string, app *App) (IBackend, error) {
|
||||
c := FtpCache.Get(params)
|
||||
if c != nil {
|
||||
if c := FtpCache.Get(params); c != nil {
|
||||
d := c.(*Ftp)
|
||||
return d, nil
|
||||
}
|
||||
|
|
@ -48,8 +48,7 @@ func (f Ftp) Init(params map[string]string, app *App) (IBackend, error) {
|
|||
|
||||
conn := 5
|
||||
if params["conn"] != "" {
|
||||
i, err := strconv.Atoi(params["conn"])
|
||||
if err == nil && i > 0 {
|
||||
if i, err := strconv.Atoi(params["conn"]); err == nil && i > 0 {
|
||||
conn = i
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +59,7 @@ func (f Ftp) Init(params map[string]string, app *App) (IBackend, error) {
|
|||
ConnectionsPerHost: conn,
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
client, err := goftp.DialConfig(config, params["hostname"]+":"+params["port"])
|
||||
client, err := goftp.DialConfig(config, fmt.Sprintf("%s:%s", params["hostname"], params["port"]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -125,19 +124,7 @@ func (f Ftp) Home() (string, error) {
|
|||
return f.client.Getwd()
|
||||
}
|
||||
|
||||
func (f Ftp) Ls(path string) ([]os.FileInfo, error) {
|
||||
// by default FTP don't seem to mind a readdir on a non existing
|
||||
// directory so we first need to make sure the directory exists
|
||||
conn, err := f.client.OpenRawConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
i, s, err := conn.SendCommand("CWD %s", path)
|
||||
if err != nil {
|
||||
return nil, NewError(err.Error(), 404)
|
||||
} else if i >= 300 {
|
||||
return nil, NewError(s, 404)
|
||||
}
|
||||
func (f Ftp) Ls(path string) ([]os.FileInfo, error) {
|
||||
return f.client.ReadDir(path)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,9 +105,10 @@ func (w WebDav) Ls(path string) ([]os.FileInfo, error) {
|
|||
return nil, NewError("Server not found", 404)
|
||||
}
|
||||
|
||||
URLDav := regexp.MustCompile(`^http[s]?://[^/]*`).ReplaceAllString(w.params.url+encodeURL(path), "")
|
||||
LongURLDav := w.params.url+encodeURL(path)
|
||||
ShortURLDav := regexp.MustCompile(`^http[s]?://[^/]*`).ReplaceAllString(LongURLDav, "")
|
||||
for _, tag := range r.Responses {
|
||||
if tag.Href == URLDav || tag.Href + "/" == URLDav {
|
||||
if tag.Href == ShortURLDav || tag.Href == LongURLDav {
|
||||
continue
|
||||
}
|
||||
for i, prop := range tag.Props {
|
||||
|
|
|
|||
Loading…
Reference in a new issue