Implement Read Only mode
This commit is contained in:
parent
6464d92dd4
commit
e1bd235785
19 changed files with 544 additions and 335 deletions
|
@ -19,7 +19,7 @@ const (
|
|||
uploadChanSize = 100
|
||||
)
|
||||
|
||||
func InitUpload(database *database.DB, store *storage.Store) {
|
||||
func InitUpload(database database.DB, store storage.Store) {
|
||||
uploadChannel = make(chan uploadRequest, uploadChanSize)
|
||||
go uploadWorker(database, store)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ type uploadRequest struct {
|
|||
filename string
|
||||
}
|
||||
|
||||
func uploadWorker(database *database.DB, store *storage.Store) {
|
||||
func uploadWorker(database database.DB, store storage.Store) {
|
||||
db := database.Copy()
|
||||
defer db.Close()
|
||||
|
||||
|
@ -40,7 +40,7 @@ func uploadWorker(database *database.DB, store *storage.Store) {
|
|||
}
|
||||
}
|
||||
|
||||
func processFile(req uploadRequest, db *database.DB, store *storage.Store) {
|
||||
func processFile(req uploadRequest, db database.DB, store storage.Store) {
|
||||
defer req.file.Close()
|
||||
|
||||
epub, err := openMultipartEpub(req.file)
|
||||
|
@ -72,6 +72,12 @@ func processFile(req uploadRequest, db *database.DB, store *storage.Store) {
|
|||
}
|
||||
|
||||
func uploadPostHandler(h handler) {
|
||||
if h.ro {
|
||||
h.sess.Notify("Upload failed!", "The library is in Read Only mode, no books can be uploaded", "error")
|
||||
uploadHandler(h)
|
||||
return
|
||||
}
|
||||
|
||||
problem := false
|
||||
|
||||
h.r.ParseMultipartForm(20000000)
|
||||
|
|
Reference in a new issue