Skip to content
Snippets Groups Projects
Commit b410e1c8 authored by Christian Pointner's avatar Christian Pointner
Browse files

added some comments for handling file creation errors

parent aac6beeb
No related branches found
No related tags found
No related merge requests found
......@@ -95,16 +95,27 @@ func (api *API) CreateFileForShow() http.Handler {
sendError(w, err)
return
}
// TODO: from here on, in case of an error we should either delete the newly created
// file or at least return the id of the created file so the UI can deal with it.
refID := "" // TODO: get this from query paremeter
job, err := api.importer.CreateJob(showID, file.ID, *srcURI, sess.Username, refID)
if err != nil {
// shall we remove the file here... thinking...
// possible errors:
// - importer.ErrSourceNotSupported -> delete file
// - any error returned by store.GetFile():
// possible reasons for this:
// * connection problem to the store database
// * somebody deleted the file
// - importer.ErrFileNotNew -> leave file
sendError(w, err)
return
}
if err = job.Start(context.Background(), 3*time.Hour); err != nil { // TODO: hardcoded value
// shall we remove the file here... thinking...
// possible errors:
// - importer.ErrAlreadyCanceled -> ??
// - error while creating job workdir -> ??
// - importer.ErrTooManyJobs -> ??
sendError(w, err)
return
}
......@@ -120,6 +131,9 @@ func (api *API) CreateFileForShow() http.Handler {
<-job.Done()
}
if file, err = api.store.GetFile(showID, file.ID); err != nil {
// possible reasons why this failed:
// - connection problem to the store database
// - somebody deleted the file
sendError(w, err)
return
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment