Remove dupe

This commit is contained in:
Dane Everitt 2020-12-15 20:20:22 -08:00
parent 904e0a574d
commit 01b766dacc
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -270,51 +270,6 @@ func postServerDownloadRemoteFile(c *gin.Context) {
c.Status(http.StatusNoContent)
}
// Writes the contents of the remote URL to a file on a server.
func postServerDownloadRemoteFile(c *gin.Context) {
s := ExtractServer(c)
var data struct {
URL string `binding:"required" json:"url"`
BasePath string `json:"path"`
}
if err := c.BindJSON(&data); err != nil {
return
}
u, err := url.Parse(data.URL)
if err != nil {
if e, ok := err.(*url.Error); ok {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "An error occurred while parsing that URL: " + e.Err.Error(),
})
return
}
TrackedServerError(err, s).AbortWithServerError(c)
return
}
resp, err := http.Get(u.String())
if err != nil {
TrackedServerError(err, s).AbortWithServerError(c)
return
}
defer resp.Body.Close()
filename := strings.Split(u.Path, "/")
if err := s.Filesystem().Writefile(filepath.Join(data.BasePath, filename[len(filename)-1]), resp.Body); err != nil {
if errors.Is(err, filesystem.ErrIsDirectory) {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "Cannot write file, name conflicts with an existing directory by the same name.",
})
return
}
TrackedServerError(err, s).AbortFilesystemError(c)
return
}
c.Status(http.StatusNoContent)
}
// Create a directory on a server.
func postServerCreateDirectory(c *gin.Context) {
s := GetServer(c.Param("server"))