Cleanup temp files and return to upload page after editing.

This commit is contained in:
Justin Hawkins 2021-12-29 21:55:29 +10:30
parent 563de29fcf
commit 2f5bb2ff36
3 changed files with 9 additions and 3 deletions

View File

@ -111,6 +111,12 @@ func (u *Uploader) UploadById(id int32) *Upload {
return nil return nil
} }
func (u *Upload) RemoveMarkupTempFile() {
if len(u.MarkedUpFilename) > 0 {
os.Remove(u.MarkedUpFilename)
}
}
func (u *Upload) processUpload() error { func (u *Upload) processUpload() error {
daulog.SendLog(fmt.Sprintf("Uploading: %s", u.OriginalFilename), daulog.LogTypeInfo) daulog.SendLog(fmt.Sprintf("Uploading: %s", u.OriginalFilename), daulog.LogTypeInfo)
@ -264,9 +270,7 @@ func (u *Upload) processUpload() error {
} }
// remove any marked up file // remove any marked up file
if len(u.MarkedUpFilename) > 0 { u.RemoveMarkupTempFile()
os.Remove(u.MarkedUpFilename)
}
if retriesRemaining == 0 { if retriesRemaining == 0 {
daulog.SendLog("Failed to upload, even after all retries", daulog.LogTypeError) daulog.SendLog("Failed to upload, even after all retries", daulog.LogTypeError)

View File

@ -148,6 +148,7 @@ function editor() {
.then(response => response.json()) // convert to json .then(response => response.json()) // convert to json
.then(json => { .then(json => {
console.log(json); console.log(json);
window.location = '/uploads.html';
}) })
} }

View File

@ -273,6 +273,7 @@ func (ws *WebService) modifyUpload(w http.ResponseWriter, r *http.Request) {
return return
} else if change == "skip" { } else if change == "skip" {
anUpload.State = upload.StateSkipped anUpload.State = upload.StateSkipped
anUpload.RemoveMarkupTempFile()
res := StartUploadResponse{Success: true, Message: "upload skipped"} res := StartUploadResponse{Success: true, Message: "upload skipped"}
resString, _ := json.Marshal(res) resString, _ := json.Marshal(res)
w.Write(resString) w.Write(resString)