Refactoring admin/delete code
This commit is contained in:
parent
2e043af31a
commit
1f6fb8565b
2 changed files with 11 additions and 8 deletions
9
admin.go
9
admin.go
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"labix.org/v2/mgo/bson"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -29,13 +28,7 @@ func deleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
book := books[0]
|
||||
if book.Cover != "" {
|
||||
os.RemoveAll(book.Cover[1:])
|
||||
}
|
||||
if book.CoverSmall != "" {
|
||||
os.RemoveAll(book.CoverSmall[1:])
|
||||
}
|
||||
os.RemoveAll(book.Path)
|
||||
DeleteBook(book)
|
||||
db.RemoveBook(id)
|
||||
|
||||
if !book.Active {
|
||||
|
|
Reference in a new issue