@@ -38,11 +38,10 @@ import (
38
38
"errors"
39
39
"fmt"
40
40
log "github.com/Sirupsen/logrus"
41
- "github.com/inconshreveable/go-update"
42
41
"github.com/kardianos/osext"
43
42
"github.com/kr/binarydist"
44
43
"github.com/pivotal-golang/archiver/extractor"
45
- patch "github.com/sanderhahn/gozip/patchzip "
44
+ "gopkg.in/inconshreveable/go-update.v0 "
46
45
"io"
47
46
"io/ioutil"
48
47
"math/rand"
@@ -69,57 +68,6 @@ func IsZip(path string) bool {
69
68
return false
70
69
}
71
70
72
- func Zip (path string , dirs []string ) (err error ) {
73
- if IsZip (path ) {
74
- return errors .New (path + " is already a zip file" )
75
- }
76
-
77
- f , err := os .OpenFile (path , os .O_RDWR | os .O_CREATE | os .O_APPEND , 0644 )
78
- if err != nil {
79
- return
80
- }
81
- defer f .Close ()
82
-
83
- startoffset , err := f .Seek (0 , os .SEEK_END )
84
- if err != nil {
85
- return
86
- }
87
-
88
- w := patch .NewWriterAt (f , startoffset )
89
-
90
- for _ , dir := range dirs {
91
- err = filepath .Walk (dir , func (path string , info os.FileInfo , err error ) error {
92
- if err != nil {
93
- return err
94
- }
95
-
96
- fh , err := patch .FileInfoHeader (info )
97
- if err != nil {
98
- return err
99
- }
100
- fh .Name = path
101
-
102
- p , err := w .CreateHeader (fh )
103
- if err != nil {
104
- return err
105
- }
106
- if ! info .IsDir () {
107
- content , err := ioutil .ReadFile (path )
108
- if err != nil {
109
- return err
110
- }
111
- _ , err = p .Write (content )
112
- if err != nil {
113
- return err
114
- }
115
- }
116
- return err
117
- })
118
- }
119
- err = w .Close ()
120
- return
121
- }
122
-
123
71
func Unzip (zippath string , destination string ) (err error ) {
124
72
r , err := zip .OpenReader (zippath )
125
73
if err != nil {
0 commit comments