]> git.lizzy.rs Git - go-anidb.git/blobdiff - mylistmanip.go
Modernize
[go-anidb.git] / mylistmanip.go
index f643c5fab5f2ff0bc8065d4f837aa3ed47fc8709..271673abeda27335629683f07438c8d309a451d5 100644 (file)
@@ -1,7 +1,7 @@
 package anidb
 
 import (
-       "github.com/Kovensky/go-fscache"
+       "github.com/EliasFleckenstein03/go-fscache"
        "strconv"
        "time"
 )
@@ -86,13 +86,29 @@ func (set *MyListSet) update(uid UID, f *File, lid LID) {
        Cache.Set(mla, "mylist-anime", uid, f.AID)
        Cache.Chtime(mla.Cached, "mylist-anime", uid, f.AID)
 
+       e := lid.MyListEntry()
        if set == nil ||
                (set.ViewDate == nil && set.Watched == nil && set.State == nil &&
                        set.Source == nil && set.Storage == nil && set.Other == nil) {
                return
        }
+       if e == nil {
+               now := time.Now()
+               e = &MyListEntry{
+                       LID: lid,
+
+                       AID: f.AID,
+                       EID: f.EID,
+                       FID: f.FID,
+                       GID: f.GID,
+
+                       DateAdded: now,
+
+                       // make sure it's expired
+                       Cached: time.Unix(0, 0),
+               }
+       }
 
-       e := lid.MyListEntry()
        if set.ViewDate != nil {
                e.DateWatched = *set.ViewDate
        } else if set.Watched != nil {