Add dupe paste checking
This commit is contained in:
parent
b20229ca98
commit
8bcc435c50
12
main.go
12
main.go
|
@ -79,6 +79,15 @@ func save(raw []byte) []string {
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
sha := hash(p)
|
sha := hash(p)
|
||||||
|
query, err := db.Query("select id, hash, paste, delkey from pastebin")
|
||||||
|
for query.Next() {
|
||||||
|
var id, hash, paste, delkey string
|
||||||
|
err := query.Scan(&id, hash, paste, delkey)
|
||||||
|
check(err)
|
||||||
|
if hash == sha {
|
||||||
|
return []string{id, hash, paste, delkey}
|
||||||
|
}
|
||||||
|
}
|
||||||
id := generateName()
|
id := generateName()
|
||||||
url := ADDRESS + "/p/" + id
|
url := ADDRESS + "/p/" + id
|
||||||
delKey := uniuri.NewLen(40)
|
delKey := uniuri.NewLen(40)
|
||||||
|
@ -94,6 +103,9 @@ func save(raw []byte) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func delHandler(w http.ResponseWriter, r *http.Request) {
|
func delHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
/* vars := mux.Vars(r)
|
||||||
|
paste := vars["pasteId"]
|
||||||
|
delkey := vars["delKey"] */
|
||||||
}
|
}
|
||||||
func saveHandler(w http.ResponseWriter, r *http.Request) {
|
func saveHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
|
Loading…
Reference in New Issue