Change the paths stored on the database
The paths in the database now are relative of the config BOOKS_PATH and COVER_PATH For updating the database this query should be use: for (var i = db.books.find(); i.hasNext(); ) { var book = i.next(); db.books.update({_id: book["_id"]}, {$set: {path: book["path"].slice(6), cover: book["cover"].slice(7), coversmall: book["coversmall"].slice(7)}}); }
This commit is contained in:
parent
34b48f411c
commit
93bd567f8d
9 changed files with 41 additions and 35 deletions
11
reader.go
11
reader.go
|
@ -125,6 +125,7 @@ func readHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var data readData
|
||||
data.Book = books[0]
|
||||
var bookPath string
|
||||
if !data.Book.Active {
|
||||
sess := GetSession(r)
|
||||
if sess.User == "" {
|
||||
|
@ -132,10 +133,12 @@ func readHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
data.Back = "/new/"
|
||||
bookPath = NEW_PATH + data.Book.Path
|
||||
} else {
|
||||
data.Back = "/book/" + id
|
||||
bookPath = BOOKS_PATH + data.Book.Path
|
||||
}
|
||||
e, _ := epub.Open(data.Book.Path, 0)
|
||||
e, _ := epub.Open(bookPath, 0)
|
||||
defer e.Close()
|
||||
if file == "" {
|
||||
it := e.Iterator(epub.EITERATOR_LINEAR)
|
||||
|
@ -158,14 +161,18 @@ func contentHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
book := books[0]
|
||||
var bookPath string
|
||||
if !book.Active {
|
||||
sess := GetSession(r)
|
||||
if sess.User == "" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
bookPath = NEW_PATH + book.Path
|
||||
} else {
|
||||
bookPath = BOOKS_PATH + book.Path
|
||||
}
|
||||
e, _ := epub.Open(book.Path, 0)
|
||||
e, _ := epub.Open(bookPath, 0)
|
||||
defer e.Close()
|
||||
if file == "" {
|
||||
http.NotFound(w, r)
|
||||
|
|
Reference in a new issue