Make genID public
This commit is contained in:
parent
645c4ce217
commit
62076ddb2f
2 changed files with 4 additions and 4 deletions
|
@ -67,7 +67,7 @@ func listPostHandler(h handler) {
|
||||||
|
|
||||||
var listID string
|
var listID string
|
||||||
if list == nil {
|
if list == nil {
|
||||||
listID = genID()
|
listID = GenID()
|
||||||
err = h.db.NewBookList(listID, listTitle, h.sess.User, []string{})
|
err = h.db.NewBookList(listID, listTitle, h.sess.User, []string{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error creating list ", listTitle, " by user ", h.sess.User, ": ", err)
|
log.Error("Error creating list ", listTitle, " by user ", h.sess.User, ": ", err)
|
||||||
|
|
|
@ -50,7 +50,7 @@ func (req uploadRequest) processFile(db database.DB, store storage.Store) {
|
||||||
defer epub.Close()
|
defer epub.Close()
|
||||||
|
|
||||||
book := parser.EpubMetadata(epub)
|
book := parser.EpubMetadata(epub)
|
||||||
book.ID = genID()
|
book.ID = GenID()
|
||||||
|
|
||||||
req.file.Seek(0, 0)
|
req.file.Seek(0, 0)
|
||||||
size, err := store.Store(book.ID, req.file, epubFile)
|
size, err := store.Store(book.ID, req.file, epubFile)
|
||||||
|
@ -89,7 +89,7 @@ func uploadPostHandler(h handler) {
|
||||||
defer h.r.MultipartForm.RemoveAll()
|
defer h.r.MultipartForm.RemoveAll()
|
||||||
|
|
||||||
filesForm := h.r.MultipartForm.File["epub"]
|
filesForm := h.r.MultipartForm.File["epub"]
|
||||||
submissionID := genID()
|
submissionID := GenID()
|
||||||
for _, f := range filesForm {
|
for _, f := range filesForm {
|
||||||
submission := database.Submission{
|
submission := database.Submission{
|
||||||
SubmissionID: submissionID,
|
SubmissionID: submissionID,
|
||||||
|
@ -159,7 +159,7 @@ func submissionCommentHandler(h handler) {
|
||||||
http.Redirect(h.w, h.r, "/submission/"+submissionID, http.StatusFound)
|
http.Redirect(h.w, h.r, "/submission/"+submissionID, http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func genID() string {
|
func GenID() string {
|
||||||
b := make([]byte, 12)
|
b := make([]byte, 12)
|
||||||
rand.Read(b)
|
rand.Read(b)
|
||||||
return base64.URLEncoding.EncodeToString(b)
|
return base64.URLEncoding.EncodeToString(b)
|
||||||
|
|
Reference in a new issue