mirror of
https://github.com/writefreely/writefreely
synced 2024-11-25 01:50:17 +00:00
Tweak user-facing upload errors + internal logs
Ref T609
This commit is contained in:
parent
03eeca179e
commit
18d3456a23
1 changed files with 8 additions and 8 deletions
|
@ -86,31 +86,31 @@ func handleImport(app *App, u *User, w http.ResponseWriter, r *http.Request) err
|
||||||
ok := func() bool {
|
ok := func() bool {
|
||||||
file, err := formFile.Open()
|
file, err := formFile.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fileErrs = append(fileErrs, fmt.Errorf("failed to open form file: %s", formFile.Filename))
|
fileErrs = append(fileErrs, fmt.Errorf("Unable to read file %s", formFile.Filename))
|
||||||
log.Error("import textfile: open from form: %v", err)
|
log.Error("import file: open from form: %v", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
tempFile, err := ioutil.TempFile("", "post-upload-*.txt")
|
tempFile, err := ioutil.TempFile("", "post-upload-*.txt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fileErrs = append(fileErrs, fmt.Errorf("failed to create temporary file for: %s", formFile.Filename))
|
fileErrs = append(fileErrs, fmt.Errorf("Internal error for %s", formFile.Filename))
|
||||||
log.Error("import textfile: create temp file: %v", err)
|
log.Error("import file: create temp file %s: %v", formFile.Filename, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
defer tempFile.Close()
|
defer tempFile.Close()
|
||||||
|
|
||||||
_, err = io.Copy(tempFile, file)
|
_, err = io.Copy(tempFile, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fileErrs = append(fileErrs, fmt.Errorf("failed to copy file into temporary location: %s", formFile.Filename))
|
fileErrs = append(fileErrs, fmt.Errorf("Internal error for %s", formFile.Filename))
|
||||||
log.Error("import textfile: copy to temp: %v", err)
|
log.Error("import file: copy to temp location %s: %v", formFile.Filename, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := tempFile.Stat()
|
info, err := tempFile.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fileErrs = append(fileErrs, fmt.Errorf("failed to get file info of: %s", formFile.Filename))
|
fileErrs = append(fileErrs, fmt.Errorf("Internal error for %s", formFile.Filename))
|
||||||
log.Error("import textfile: stat temp file: %v", err)
|
log.Error("import file: stat temp file %s: %v", formFile.Filename, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
fname = info.Name()
|
fname = info.Name()
|
||||||
|
|
Loading…
Reference in a new issue