Auto-create books directory, log upload errors, document Docker deployment
- library.New now creates BOOKS_DIR (MkdirAll) on startup so uploads don't fail when the directory is missing on a fresh bind mount - uploadSubmit logs the underlying OS error on save/write failures - README: document docker-compose deployment, container UID/GID (100/101) for bind-mounted ./data permissions, and running the admin CLI via docker compose exec Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -232,12 +233,14 @@ func (h *Handler) uploadSubmit(w http.ResponseWriter, r *http.Request) {
|
||||
render(w, r.Context(), views.UploadPage(fmt.Sprintf("Datei '%s' existiert bereits.", safeFilename)))
|
||||
return
|
||||
}
|
||||
log.Printf("upload: create %q failed: %v", destPath, err)
|
||||
http.Error(w, "Datei konnte nicht gespeichert werden", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
if _, err := io.Copy(out, file); err != nil {
|
||||
log.Printf("upload: write %q failed: %v", destPath, err)
|
||||
_ = os.Remove(destPath)
|
||||
http.Error(w, "Upload fehlgeschlagen", http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user