Commit 43ec4da2 authored by Ronny Bangsund's avatar Ronny Bangsund

Bugfix/tweak.

-Pointers in struct funcs
-Delete scraps from global list when deleting files
parent d895e920
......@@ -27,7 +27,7 @@ type Scrap struct {
Expiry int64
}
func (s Scrap) hasExpired() bool {
func (s *Scrap) hasExpired() bool {
if s.Expiry < time.Now().Unix() {
if s.Hash != "" {
info("%s has expired.", s.Hash)
......@@ -38,7 +38,7 @@ func (s Scrap) hasExpired() bool {
return false
}
func (s Scrap) getHash() string {
func (s *Scrap) getHash() string {
hash := sha3.NewKeccak256()
io.WriteString(hash, s.User)
io.WriteString(hash, s.Content)
......@@ -46,7 +46,7 @@ func (s Scrap) getHash() string {
return fmt.Sprintf("%x", hash.Sum(nil))
}
func (s Scrap) save() bool {
func (s *Scrap) save() bool {
_, ok := languages[s.Language]
if !ok {
// Unsupported language (poster probably modified source)
......@@ -97,9 +97,10 @@ func loadScrap(hash string) Scrap {
return s
}
func (s Scrap) delete() {
func (s *Scrap) delete() {
os.Remove("./data/" + s.Hash)
os.Remove("./data/" + s.Language + "/" + s.Hash)
delete(scraps s)
}
// Open all index files and load the associated scrap,
......
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