mirror of
https://github.com/drone-plugins/drone-download.git
synced 2026-06-04 18:24:21 +08:00
impl #14
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jackspirou/syscerts"
|
"github.com/jackspirou/syscerts"
|
||||||
@@ -45,6 +46,17 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destination = path.Base(u.Path)
|
destination = path.Base(u.Path)
|
||||||
|
} else if destination[len(destination)-1] == '/' {
|
||||||
|
_ = os.MkdirAll(destination, os.ModePerm)
|
||||||
|
u, err := url.Parse(p.Config.Source)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "parsing source failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
destination = destination + path.Base(u.Path)
|
||||||
|
} else {
|
||||||
|
_ = os.MkdirAll(destination[0:strings.LastIndex(destination, "/")], os.ModePerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("downloading to %s", destination)
|
log.Printf("downloading to %s", destination)
|
||||||
|
|||||||
Reference in New Issue
Block a user