Allow excluding metadata from built assets
This commit is contained in:
parent
dce55d09e2
commit
7f4fb1184f
|
@ -127,6 +127,8 @@ type Config struct {
|
||||||
// repository.
|
// repository.
|
||||||
Dev bool
|
Dev bool
|
||||||
|
|
||||||
|
// When true, size, mode and modtime are not preserved from files
|
||||||
|
NoMetadata bool
|
||||||
// When nonzero, use this as mode for all files.
|
// When nonzero, use this as mode for all files.
|
||||||
Mode uint
|
Mode uint
|
||||||
// When nonzero, use this as unix timestamp for all files.
|
// When nonzero, use this as unix timestamp for all files.
|
||||||
|
|
|
@ -47,6 +47,7 @@ func parseArgs() *bindata.Config {
|
||||||
flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.")
|
flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.")
|
||||||
flag.BoolVar(&c.NoMemCopy, "nomemcopy", c.NoMemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.")
|
flag.BoolVar(&c.NoMemCopy, "nomemcopy", c.NoMemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.")
|
||||||
flag.BoolVar(&c.NoCompress, "nocompress", c.NoCompress, "Assets will *not* be GZIP compressed when this flag is specified.")
|
flag.BoolVar(&c.NoCompress, "nocompress", c.NoCompress, "Assets will *not* be GZIP compressed when this flag is specified.")
|
||||||
|
flag.BoolVar(&c.NoMetadata, "nometadata", c.NoMetadata, "Assets will not preserve size, mode, and modtime info.")
|
||||||
flag.UintVar(&c.Mode, "mode", c.Mode, "Optional file mode override for all files.")
|
flag.UintVar(&c.Mode, "mode", c.Mode, "Optional file mode override for all files.")
|
||||||
flag.Int64Var(&c.ModTime, "modtime", c.ModTime, "Optional modification unix timestamp override for all files.")
|
flag.Int64Var(&c.ModTime, "modtime", c.ModTime, "Optional modification unix timestamp override for all files.")
|
||||||
flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.")
|
flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.")
|
||||||
|
|
|
@ -359,7 +359,12 @@ func asset_release_common(w io.Writer, c *Config, asset *Asset) error {
|
||||||
|
|
||||||
mode := uint(fi.Mode())
|
mode := uint(fi.Mode())
|
||||||
modTime := fi.ModTime().Unix()
|
modTime := fi.ModTime().Unix()
|
||||||
|
size := fi.Size()
|
||||||
|
if c.NoMetadata {
|
||||||
|
mode = 0
|
||||||
|
modTime = 0
|
||||||
|
size = 0
|
||||||
|
}
|
||||||
if c.Mode > 0 {
|
if c.Mode > 0 {
|
||||||
mode = uint(os.ModePerm) & c.Mode
|
mode = uint(os.ModePerm) & c.Mode
|
||||||
}
|
}
|
||||||
|
@ -377,6 +382,6 @@ func asset_release_common(w io.Writer, c *Config, asset *Asset) error {
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
`, asset.Func, asset.Func, asset.Name, fi.Size(), mode, modTime)
|
`, asset.Func, asset.Func, asset.Name, size, mode, modTime)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user