summaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-01-07 10:33:17 +0800
committerGitHub <noreply@github.com>2022-01-06 21:33:17 -0500
commita1c12fb0b3a88e21e4c8c8f29c13e63cf4bc38dd (patch)
tree7add88555600d96deecbc9f97217d183f83f3edc /vendor/github.com
parent21ed4fd8da4c8992518dcfb01aa7306f7406f735 (diff)
downloadgitea-a1c12fb0b3a88e21e4c8c8f29c13e63cf4bc38dd.tar.gz
gitea-a1c12fb0b3a88e21e4c8c8f29c13e63cf4bc38dd.zip
Don't store assets modified time into generated files (#18193)
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/shurcooL/vfsgen/generator.go38
-rw-r--r--vendor/github.com/shurcooL/vfsgen/options.go4
2 files changed, 30 insertions, 12 deletions
diff --git a/vendor/github.com/shurcooL/vfsgen/generator.go b/vendor/github.com/shurcooL/vfsgen/generator.go
index c0067c5d36..dfe6c24a5e 100644
--- a/vendor/github.com/shurcooL/vfsgen/generator.go
+++ b/vendor/github.com/shurcooL/vfsgen/generator.go
@@ -30,7 +30,9 @@ func Generate(input http.FileSystem, opt Options) error {
return err
}
- var toc toc
+ var toc = toc{
+ UseGlobalModTime: opt.UseGlobalModTime,
+ }
err = findAndWriteFiles(buf, input, &toc)
if err != nil {
return err
@@ -56,6 +58,8 @@ type toc struct {
HasCompressedFile bool // There's at least one compressedFile.
HasFile bool // There's at least one uncompressed file.
+ UseGlobalModTime bool // copy from opt
+
}
// fileInfo is a definition of a file.
@@ -64,14 +68,16 @@ type fileInfo struct {
Name string
ModTime time.Time
UncompressedSize int64
+ UseGlobalModTime bool
}
// dirInfo is a definition of a directory.
type dirInfo struct {
- Path string
- Name string
- ModTime time.Time
- Entries []string
+ Path string
+ Name string
+ ModTime time.Time
+ Entries []string
+ UseGlobalModTime bool
}
// findAndWriteFiles recursively finds all the file paths in the given directory tree.
@@ -91,6 +97,7 @@ func findAndWriteFiles(buf *bytes.Buffer, fs http.FileSystem, toc *toc) error {
Name: pathpkg.Base(path),
ModTime: fi.ModTime().UTC(),
UncompressedSize: fi.Size(),
+ UseGlobalModTime: toc.UseGlobalModTime,
}
marker := buf.Len()
@@ -125,10 +132,11 @@ func findAndWriteFiles(buf *bytes.Buffer, fs http.FileSystem, toc *toc) error {
}
dir := &dirInfo{
- Path: path,
- Name: pathpkg.Base(path),
- ModTime: fi.ModTime().UTC(),
- Entries: entries,
+ Path: path,
+ Name: pathpkg.Base(path),
+ ModTime: fi.ModTime().UTC(),
+ Entries: entries,
+ UseGlobalModTime: toc.UseGlobalModTime,
}
toc.dirs = append(toc.dirs, dir)
@@ -242,7 +250,9 @@ var {{.VariableName}} = func() http.FileSystem {
{{define "CompressedFileInfo-Before"}} {{quote .Path}}: &vfsgen۰CompressedFileInfo{
name: {{quote .Name}},
+ {{if not .UseGlobalModTime}}
modTime: {{template "Time" .ModTime}},
+ {{end}}
uncompressedSize: {{.UncompressedSize}},
{{/* This blank line separating compressedContent is neccessary to prevent potential gofmt issues. See issue #19. */}}
compressedContent: []byte("{{end}}{{define "CompressedFileInfo-After"}}"),
@@ -253,7 +263,9 @@ var {{.VariableName}} = func() http.FileSystem {
{{define "FileInfo-Before"}} {{quote .Path}}: &vfsgen۰FileInfo{
name: {{quote .Name}},
+ {{if not .UseGlobalModTime}}
modTime: {{template "Time" .ModTime}},
+ {{end}}
content: []byte("{{end}}{{define "FileInfo-After"}}"),
},
{{end}}
@@ -262,7 +274,9 @@ var {{.VariableName}} = func() http.FileSystem {
{{define "DirInfo"}} {{quote .Path}}: &vfsgen۰DirInfo{
name: {{quote .Name}},
+ {{if not .UseGlobalModTime}}
modTime: {{template "Time" .ModTime}},
+ {{end}}
},
{{end}}
@@ -335,7 +349,7 @@ func (f *vfsgen۰CompressedFileInfo) GzipBytes() []byte {
func (f *vfsgen۰CompressedFileInfo) Name() string { return f.name }
func (f *vfsgen۰CompressedFileInfo) Size() int64 { return f.uncompressedSize }
func (f *vfsgen۰CompressedFileInfo) Mode() os.FileMode { return 0444 }
-func (f *vfsgen۰CompressedFileInfo) ModTime() time.Time { return f.modTime }
+func (f *vfsgen۰CompressedFileInfo) ModTime() time.Time { return {{if .UseGlobalModTime}}GlobalModTime(f.name){{else}}f.modTime{{end}} }
func (f *vfsgen۰CompressedFileInfo) IsDir() bool { return false }
func (f *vfsgen۰CompressedFileInfo) Sys() interface{} { return nil }
@@ -407,7 +421,7 @@ func (f *vfsgen۰FileInfo) NotWorthGzipCompressing() {}
func (f *vfsgen۰FileInfo) Name() string { return f.name }
func (f *vfsgen۰FileInfo) Size() int64 { return int64(len(f.content)) }
func (f *vfsgen۰FileInfo) Mode() os.FileMode { return 0444 }
-func (f *vfsgen۰FileInfo) ModTime() time.Time { return f.modTime }
+func (f *vfsgen۰FileInfo) ModTime() time.Time { return {{if .UseGlobalModTime}}GlobalModTime(f.name){{else}}f.modTime{{end}} }
func (f *vfsgen۰FileInfo) IsDir() bool { return false }
func (f *vfsgen۰FileInfo) Sys() interface{} { return nil }
@@ -440,7 +454,7 @@ func (d *vfsgen۰DirInfo) Stat() (os.FileInfo, error) { return d, nil }
func (d *vfsgen۰DirInfo) Name() string { return d.name }
func (d *vfsgen۰DirInfo) Size() int64 { return 0 }
func (d *vfsgen۰DirInfo) Mode() os.FileMode { return 0755 | os.ModeDir }
-func (d *vfsgen۰DirInfo) ModTime() time.Time { return d.modTime }
+func (d *vfsgen۰DirInfo) ModTime() time.Time { return {{if .UseGlobalModTime}}GlobalModTime(d.name){{else}}d.modTime{{end}} }
func (d *vfsgen۰DirInfo) IsDir() bool { return true }
func (d *vfsgen۰DirInfo) Sys() interface{} { return nil }
diff --git a/vendor/github.com/shurcooL/vfsgen/options.go b/vendor/github.com/shurcooL/vfsgen/options.go
index d10d348e70..40f43a697a 100644
--- a/vendor/github.com/shurcooL/vfsgen/options.go
+++ b/vendor/github.com/shurcooL/vfsgen/options.go
@@ -26,6 +26,10 @@ type Options struct {
// VariableComment is the comment of the http.FileSystem variable in the generated code.
// If left empty, it defaults to "{{.VariableName}} statically implements the virtual filesystem provided to vfsgen.".
VariableComment string
+
+ // UseGlobalModTime indicates that not retrieve files' modified time if it's true. Once this
+ // is true, you have to define a function GlobalModTime(filename string) time.Time in the same package of generated files
+ UseGlobalModTime bool
}
// fillMissing sets default values for mandatory options that are left empty.