ready for v1.0rc1
This commit is contained in:
parent
84d48a6eea
commit
ce5764840f
15 changed files with 140 additions and 49 deletions
|
|
@ -280,7 +280,7 @@ func newDirHandler(ctx *Context) {
|
|||
|
||||
func moveHandler(ctx *Context) {
|
||||
path := strings.TrimPrefix(ctx.Path(), core.MovePrefix)
|
||||
mode, err := ctx.Srv.FS.Mode(path)
|
||||
mode, _, err := ctx.Srv.FS.Mode(path)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
|
|
@ -323,11 +323,12 @@ func moveHandler(ctx *Context) {
|
|||
return
|
||||
}
|
||||
for _, m := range moved {
|
||||
log.Debugf("move: %s to %s", m.Old, m.New)
|
||||
err = ctx.Srv.DB.MoveFile(m.Old, m.New)
|
||||
if err != nil {
|
||||
log.Printf("move: %s: %s", m, err)
|
||||
continue
|
||||
}
|
||||
log.Debugf("move: %s to %s", m.Old, m.New)
|
||||
}
|
||||
ctx.Redirect(newfile, http.StatusFound)
|
||||
}
|
||||
|
|
@ -335,8 +336,8 @@ func moveHandler(ctx *Context) {
|
|||
|
||||
func deleteHandler(ctx *Context) {
|
||||
path := strings.TrimPrefix(ctx.Path(), core.DeletePrefix)
|
||||
mode, err := ctx.Srv.FS.Mode(path)
|
||||
if err != nil {
|
||||
mode, enoent, err := ctx.Srv.FS.Mode(path)
|
||||
if !enoent && err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
|
|
@ -352,12 +353,14 @@ func deleteHandler(ctx *Context) {
|
|||
BodyTitle: "Delete Directory",
|
||||
}
|
||||
default:
|
||||
ctx.Data = webData{
|
||||
Title: "Delete",
|
||||
BodyTitle: "Delete",
|
||||
if ctx.Method() == "GET" {
|
||||
ctx.Data = webData{
|
||||
Title: "Delete",
|
||||
BodyTitle: "Delete",
|
||||
}
|
||||
ctx.Error(noSuchFile)
|
||||
return
|
||||
}
|
||||
ctx.Error(noSuchFile)
|
||||
return
|
||||
}
|
||||
ctx.Data.Path = path
|
||||
ctx.Data.Data = mode
|
||||
|
|
@ -369,6 +372,27 @@ func deleteHandler(ctx *Context) {
|
|||
if !ctx.CheckXsrf() {
|
||||
return
|
||||
}
|
||||
p, _ := filepath.Split(path)
|
||||
p = filepath.Dir(p)
|
||||
clean := ctx.Form("clean")
|
||||
if clean == "true" {
|
||||
f := fs.Clean(path)
|
||||
id, err := ctx.Srv.DB.DeleteFile(f)
|
||||
if err != nil {
|
||||
log.Printf("db: delete: %s %s", f, err)
|
||||
}
|
||||
if id == "" {
|
||||
ctx.Redirect(p, http.StatusFound)
|
||||
return
|
||||
}
|
||||
log.Debugf("delete %s id: %s from index", f, id)
|
||||
err = ctx.Srv.DB.Index.Delete(id)
|
||||
if err != nil {
|
||||
log.Printf("index: delete: %s %s", f, err)
|
||||
}
|
||||
ctx.Redirect(p, http.StatusFound)
|
||||
return
|
||||
}
|
||||
files, err := ctx.Srv.FS.Delete(path)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
|
|
@ -379,17 +403,15 @@ func deleteHandler(ctx *Context) {
|
|||
if err != nil {
|
||||
log.Printf("db: delete: %s %s", f, err)
|
||||
}
|
||||
log.Debugf("delete %s id: %s from index", f, id)
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
log.Debugf("delete %s id: %s from index", f, id)
|
||||
err = ctx.Srv.DB.Index.Delete(id)
|
||||
if err != nil {
|
||||
log.Printf("index: delete: %s %s", f, err)
|
||||
}
|
||||
}
|
||||
p, _ := filepath.Split(path)
|
||||
p = filepath.Dir(p)
|
||||
ctx.Redirect(p, http.StatusFound)
|
||||
}
|
||||
}
|
||||
|
|
@ -399,8 +421,8 @@ func dirHandler(ctx *Context) {
|
|||
path := ctx.Path()
|
||||
switch ctx.Method() {
|
||||
case "GET":
|
||||
mode, err := ctx.Srv.FS.Mode(path)
|
||||
if err != nil {
|
||||
mode, enoent, err := ctx.Srv.FS.Mode(path)
|
||||
if !enoent && err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
|
|
@ -429,10 +451,17 @@ func dirHandler(ctx *Context) {
|
|||
ctx.Data.Paths = fs.Paths(path)
|
||||
ctx.Exec()
|
||||
default:
|
||||
ctx.Data = webData{
|
||||
Title: "Viewer",
|
||||
p := fs.Clean(path)
|
||||
if enoent && ctx.Srv.DB.IsIndexed(p) {
|
||||
ctx.Template("enoentHandler")
|
||||
ctx.Data = webData{
|
||||
Title: "Stalled File",
|
||||
}
|
||||
ctx.Data.Path = p
|
||||
ctx.Exec()
|
||||
return
|
||||
}
|
||||
ctx.Error(noSuchFile)
|
||||
ctx.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue