Make genID public

This commit is contained in:
Las Zenow 2018-07-01 14:35:09 +00:00
parent 645c4ce217
commit 62076ddb2f
2 changed files with 4 additions and 4 deletions

View file

@ -67,7 +67,7 @@ func listPostHandler(h handler) {
var listID string
if list == nil {
listID = genID()
listID = GenID()
err = h.db.NewBookList(listID, listTitle, h.sess.User, []string{})
if err != nil {
log.Error("Error creating list ", listTitle, " by user ", h.sess.User, ": ", err)

View file

@ -50,7 +50,7 @@ func (req uploadRequest) processFile(db database.DB, store storage.Store) {
defer epub.Close()
book := parser.EpubMetadata(epub)
book.ID = genID()
book.ID = GenID()
req.file.Seek(0, 0)
size, err := store.Store(book.ID, req.file, epubFile)
@ -89,7 +89,7 @@ func uploadPostHandler(h handler) {
defer h.r.MultipartForm.RemoveAll()
filesForm := h.r.MultipartForm.File["epub"]
submissionID := genID()
submissionID := GenID()
for _, f := range filesForm {
submission := database.Submission{
SubmissionID: submissionID,
@ -159,7 +159,7 @@ func submissionCommentHandler(h handler) {
http.Redirect(h.w, h.r, "/submission/"+submissionID, http.StatusFound)
}
func genID() string {
func GenID() string {
b := make([]byte, 12)
rand.Read(b)
return base64.URLEncoding.EncodeToString(b)