mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
fix invalid separator char in packing with prefix folder string in OS widnows for package gres
This commit is contained in:
parent
ff70e54e3e
commit
5a4de52900
@ -154,7 +154,7 @@ func (c *Client) SetPrefix(prefix string) *Client {
|
||||
return c
|
||||
}
|
||||
|
||||
// SetTimeOut sets the request timeout for the client.
|
||||
// SetTimeout sets the request timeout for the client.
|
||||
func (c *Client) SetTimeout(t time.Duration) *Client {
|
||||
c.Client.Timeout = t
|
||||
return c
|
||||
|
@ -33,7 +33,7 @@ func (c *Client) Header(m map[string]string) *Client {
|
||||
return newClient
|
||||
}
|
||||
|
||||
// Header is a chaining function,
|
||||
// HeaderRaw is a chaining function,
|
||||
// which sets custom HTTP header using raw string for next request.
|
||||
func (c *Client) HeaderRaw(headers string) *Client {
|
||||
newClient := c
|
||||
@ -92,7 +92,7 @@ func (c *Client) ContentXml() *Client {
|
||||
return newClient
|
||||
}
|
||||
|
||||
// TimeOut is a chaining function,
|
||||
// Timeout is a chaining function,
|
||||
// which sets the timeout for next request.
|
||||
func (c *Client) Timeout(t time.Duration) *Client {
|
||||
newClient := c
|
||||
|
@ -61,14 +61,14 @@ func doZipPathWriter(path string, exclude string, zipWriter *zip.Writer, prefix
|
||||
if len(prefix) > 0 && prefix[0] != "" {
|
||||
headerPrefix = prefix[0]
|
||||
}
|
||||
headerPrefix = strings.TrimRight(headerPrefix, "\\/")
|
||||
headerPrefix = strings.TrimRight(headerPrefix, `\/`)
|
||||
if len(headerPrefix) > 0 && gfile.IsDir(path) {
|
||||
headerPrefix += "/"
|
||||
}
|
||||
if headerPrefix == "" {
|
||||
headerPrefix = gfile.Basename(path)
|
||||
}
|
||||
headerPrefix = strings.Replace(headerPrefix, "//", "/", -1)
|
||||
headerPrefix = strings.Replace(headerPrefix, `//`, `/`, -1)
|
||||
for _, file := range files {
|
||||
if exclude == file {
|
||||
intlog.Printf(context.TODO(), `exclude file path: %s`, file)
|
||||
@ -84,14 +84,14 @@ func doZipPathWriter(path string, exclude string, zipWriter *zip.Writer, prefix
|
||||
var name string
|
||||
path = headerPrefix
|
||||
for {
|
||||
name = gfile.Basename(path)
|
||||
name = strings.Replace(gfile.Basename(path), `\`, `/`, -1)
|
||||
err = zipFileVirtual(
|
||||
fileinfo.New(name, 0, os.ModeDir|os.ModePerm, time.Now()), path, zipWriter,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if path == "/" || !strings.Contains(path, "/") {
|
||||
if path == `/` || !strings.Contains(path, `/`) {
|
||||
break
|
||||
}
|
||||
path = gfile.Dir(path)
|
||||
@ -103,7 +103,7 @@ func doZipPathWriter(path string, exclude string, zipWriter *zip.Writer, prefix
|
||||
// zipFile compresses the file of given <path> and writes the content to <zw>.
|
||||
// The parameter <prefix> indicates the path prefix for zip file.
|
||||
func zipFile(path string, prefix string, zw *zip.Writer) error {
|
||||
prefix = strings.Replace(prefix, "//", "/", -1)
|
||||
prefix = strings.Replace(prefix, `//`, `/`, -1)
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
2
os/gres/testdata/data/data.go
vendored
2
os/gres/testdata/data/data.go
vendored
File diff suppressed because one or more lines are too long
2
os/gres/testdata/testdata.go
vendored
2
os/gres/testdata/testdata.go
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user