[REV] After importing the cleanup directory, change the status to cleaned

This commit is contained in:
zhoujunhao 2018-09-25 21:55:51 +08:00
parent 8469e31562
commit 3b7472ef44
2 changed files with 14 additions and 2 deletions

View File

@ -131,9 +131,16 @@ func (a *AppStruct) ImportID(w http.ResponseWriter, r *http.Request) {
case "DELETE":
err := os.RemoveAll(dirName)
if err != nil {
httputil.ReturnError(r, w, 502, "Failed to delete directory by id: "+eventId)
httputil.ReturnError(r, w, 501, "Failed to delete directory by id: "+eventId)
return
}
res, err := db.GetManager().AppDao().GetByEventId(eventId)
if err != nil {
httputil.ReturnError(r, w, 502, fmt.Sprintf("Failed to query status of export app by event id %s: %v", eventId, err))
return
}
res.Status = "cleaned"
db.GetManager().AppDao().UpdateModel(res)
httputil.ReturnSuccess(r, w, "successful")
}
@ -231,6 +238,11 @@ func (a *AppStruct) ImportApp(w http.ResponseWriter, r *http.Request) {
httputil.ReturnError(r, w, 502, fmt.Sprintf("Failed to query status of export app by event id %s: %v", eventId, err))
return
}
if res.Status == "cleaned" {
res.Metadata = ""
httputil.ReturnSuccess(r, w, res)
return
}
if res.Status == "success" {
metadatasFile := fmt.Sprintf("%s/metadatas.json", res.SourceDir)

View File

@ -5,7 +5,7 @@ type AppStatus struct {
Format string `gorm:"column:format;size:32" json:"format"` // only rainbond-app/docker-compose
SourceDir string `gorm:"column:source_dir;size:255" json:"source_dir"`
Apps string `gorm:"column:apps;type:text" json:"apps"`
Status string `gorm:"column:status;size:32" json:"status"` // only exporting/importing/failed/success
Status string `gorm:"column:status;size:32" json:"status"` // only exporting/importing/failed/success/cleaned
TarFileHref string `gorm:"column:tar_file_href;size:255" json:"tar_file_href"`
Metadata string `gorm:"column:metadata;type:text" json:"metadata"`
}