Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we close the open files each time. #39

Merged
merged 1 commit into from
Jan 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion appended.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ func init() {
if err != nil {
return // not apended or cant find self executable
}
rd, err := zipexe.Open(thisFile)
closer, rd, err := zipexe.Open(thisFile)
if err != nil {
return // not apended
}
defer closer.Close()

for _, f := range rd.File {
// get box and file name from f.Name
Expand Down
2 changes: 1 addition & 1 deletion box.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ func (b *Box) Bytes(name string) ([]byte, error) {
if err != nil {
return nil, err
}
defer rc.Close()
cpy, err := ioutil.ReadAll(rc)
if err != nil {
return nil, err
}
rc.Close()
return cpy, nil
}

Expand Down
6 changes: 3 additions & 3 deletions virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ func (vf *virtualFile) seek(offset int64, whence int) (int64, error) {
return vf.offset, nil
}

// vritualDir is a 'stateful' virtual directory.
// vritualDir wraps an *EmbeddedDir for a call to Box.Open() and virtualizes 'closing'.
// vritualDir is only internally visible and should be exposed through rice.File
// virtualDir is a 'stateful' virtual directory.
// virtualDir wraps an *EmbeddedDir for a call to Box.Open() and virtualizes 'closing'.
// virtualDir is only internally visible and should be exposed through rice.File
type virtualDir struct {
*embedded.EmbeddedDir
offset int // readdir positon on the directory
Expand Down
4 changes: 3 additions & 1 deletion walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func (b *Box) Walk(path string, walkFn filepath.WalkFunc) error {
if err != nil {
return err
}
defer pathFile.Close()

pathInfo, err := pathFile.Stat()
if err != nil {
Expand Down Expand Up @@ -64,6 +65,7 @@ func (b *Box) walk(path string, info os.FileInfo, walkFn filepath.WalkFunc) erro
if err != nil {
return err
}
defer fileObject.Close()

fileInfo, err := fileObject.Stat()
if err != nil {
Expand Down Expand Up @@ -92,6 +94,7 @@ func (b *Box) readDirNames(path string) ([]string, error) {
if err != nil {
return nil, err
}
defer f.Close()

stat, err := f.Stat()
if err != nil {
Expand All @@ -103,7 +106,6 @@ func (b *Box) readDirNames(path string) ([]string, error) {
}

infos, err := f.Readdir(0)
f.Close()
if err != nil {
return nil, err
}
Expand Down