Commit 7545a311 authored by Ronny Bangsund's avatar Ronny Bangsund

Moved title generation into getHash().

parent 2f0ab0ec
......@@ -44,7 +44,9 @@ func (s *Scrap) getHash() string {
io.WriteString(hash, s.User)
io.WriteString(hash, s.Content)
io.WriteString(hash, fmt.Sprintf("%d", s.Expiry))
return fmt.Sprintf("%x", hash.Sum(nil))
r := fmt.Sprintf("%x", hash.Sum(nil))
s.Title = r[:8] + "..."
return r
}
func (s *Scrap) save() bool {
......
......@@ -127,7 +127,6 @@ func post_scrap(ctx *web.Context) {
Expiry: now + when,
}
s.Hash = s.getHash()
s.Title = s.Hash[:8] + "..."
if s.save() {
scraps[s.Hash] = s
info("Saved scrap %s.", s.Hash)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment