Skip to content

Commit

Permalink
Merge pull request #144 from alecthomas/master
Browse files Browse the repository at this point in the history
Support .Time() on appended boxes.
  • Loading branch information
GeertJohan authored Sep 2, 2019
2 parents c880e3c + 961b99d commit 2cd2eb8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions appended.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type appendedBox struct {
Name string // box name
Files map[string]*appendedFile // appended files (*zip.File) by full path
Time time.Time
}

type appendedFile struct {
Expand Down Expand Up @@ -59,6 +60,7 @@ func init() {
box = &appendedBox{
Name: boxName,
Files: make(map[string]*appendedFile),
Time: f.ModTime(),
}
appendedBoxes[boxName] = box
}
Expand All @@ -71,8 +73,7 @@ func init() {
af.dir = true
af.dirInfo = &appendedDirInfo{
name: filepath.Base(af.zipFile.Name),
//++ TODO: use zip modtime when that is set correctly: af.zipFile.ModTime()
time: time.Now(),
time: af.zipFile.ModTime(),
}
} else {
// this is a file, we need it's contents so we can create a bytes.Reader when the file is opened
Expand Down
4 changes: 3 additions & 1 deletion box.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ func (b *Box) Time() time.Time {
return b.embed.Time
}

//++ TODO: return time for appended box
if b.IsAppended() {
return b.appendd.Time
}

return time.Now()
}
Expand Down
10 changes: 6 additions & 4 deletions rice/append.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ func operationAppend(pkgs []*build.Package) {
zipFileName := filepath.Join(appendedBoxName, strings.TrimPrefix(path, boxPath))
// write directories as empty file with comment "dir"
if info.IsDir() {
_, err := zipWriter.CreateHeader(&zip.FileHeader{
Name: zipFileName,
Comment: "dir",
})
header := &zip.FileHeader{
Name: zipFileName,
Comment: "dir",
}
header.SetModTime(info.ModTime())
_, err := zipWriter.CreateHeader(header)
if err != nil {
fmt.Printf("Error creating dir in tmp zip: %s\n", err)
os.Exit(1)
Expand Down

0 comments on commit 2cd2eb8

Please sign in to comment.