Compare commits

...
2 Commits
2 changed files with 19 additions and 6 deletions
+10 -1
View File
@@ -3,6 +3,8 @@ package migrations
import (
"fmt"
"path/filepath"
"runtime"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
@@ -20,7 +22,14 @@ func Register(
down func(db dbx.Builder) error,
optFilename ...string,
) {
AppMigrations.Register(up, down, optFilename...)
var optFiles []string
if len(optFilename) > 0 {
optFiles = optFilename
} else {
_, path, _, _ := runtime.Caller(1)
optFiles = append(optFiles, filepath.Base(path))
}
AppMigrations.Register(up, down, optFiles...)
}
func init() {
+9 -5
View File
@@ -182,14 +182,18 @@ func (s *System) Serve(response http.ResponseWriter, fileKey string, name string
}
defer r.Close()
// All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT)
// (see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1)
location, _ := time.LoadLocation("GMT")
response.Header().Set("Content-Disposition", "attachment; filename="+name)
response.Header().Set("Content-Type", r.ContentType())
response.Header().Set("Content-Length", strconv.FormatInt(r.Size(), 10))
response.Header().Set("Last-Modified", r.ModTime().In(location).Format("Mon, 02 Jan 06 15:04:05 MST"))
// All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT)
// (see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1)
//
// NB! time.LoadLocation may fail on non-Unix systems (see https://github.com/pocketbase/pocketbase/issues/45)
location, locationErr := time.LoadLocation("GMT")
if locationErr == nil {
response.Header().Set("Last-Modified", r.ModTime().In(location).Format("Mon, 02 Jan 06 15:04:05 MST"))
}
// copy from the read range to response.
_, err := io.Copy(response, r)