mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-05 05:51:44 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b2d88fa30 | ||
|
|
72cb2d3f43 |
No files matched your search
@@ -3,6 +3,8 @@ package migrations
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
"github.com/pocketbase/pocketbase/daos"
|
||||||
@@ -20,7 +22,14 @@ func Register(
|
|||||||
down func(db dbx.Builder) error,
|
down func(db dbx.Builder) error,
|
||||||
optFilename ...string,
|
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() {
|
func init() {
|
||||||
|
|||||||
@@ -182,14 +182,18 @@ func (s *System) Serve(response http.ResponseWriter, fileKey string, name string
|
|||||||
}
|
}
|
||||||
defer r.Close()
|
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-Disposition", "attachment; filename="+name)
|
||||||
response.Header().Set("Content-Type", r.ContentType())
|
response.Header().Set("Content-Type", r.ContentType())
|
||||||
response.Header().Set("Content-Length", strconv.FormatInt(r.Size(), 10))
|
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.
|
// copy from the read range to response.
|
||||||
_, err := io.Copy(response, r)
|
_, err := io.Copy(response, r)
|
||||||
|
|||||||
Reference in new issue
Block a user