// Add marks c as fully-pinned by iid.
// If c is already stage-pinned, then is switched to fully-pinned.
// If c is already fully-pinned, then only its timestamp gets refreshed.
Add marks c as fully-pinned by iid.
If c is already stage-pinned, then is switched to fully-pinned.
If c is already fully-pinned, then only its timestamp gets refreshed.
// Add marks c as fully - pinned by iid . // If c is already stage - pinned then is switched to fully - pinned . // If c is already fully - pinned then only its timestamp gets refreshed .
func (s *Store) Add(iid ffs.APIID, c cid.Cid) error {
	s.lock.Lock()
	defer s.lock.Unlock()
	var r PinnedCid
	if cr, ok := s.cache[c]; ok {
		r = cr
	} else {
		r = PinnedCid{Cid: c}
	}
	var p *Pin
	for i := range r.Pins {
		if r.Pins[i].APIID == iid {
			p = &r.Pins[i]
			if !p.Staged {
				log.Warnf("%s re-pinning already pinned %s", iid, c)
			}
			break
		}
	}
	if p == nil {
		r.Pins = append(r.Pins, Pin{})
		p = &r.Pins[len(r.Pins)-1]
	}
	*p = Pin{
		APIID:     iid,
		Staged:    false,
		CreatedAt: time.Now().Unix(),
	}
	return s.persist(r)
}
func ( s * Store ) Add ( iid ffs . APIID , c cid . Cid ) error { s . lock . Lock ( ) defer s . lock . Unlock ( ) var r PinnedCid if cr , ok := s . cache [ c ] ; ok { r = cr } else { r = PinnedCid { Cid : c } } var p * Pin for i := range r . Pins { if r . Pins [ i ] . APIID == iid { p = & r . Pins [ i ] if ! p . Staged { log . Warnf ( " " , iid , c ) } break } } if p == nil { r . Pins = append ( r . Pins , Pin { } ) p = & r . Pins [ len ( r . Pins ) - 1 ] } * p = Pin { APIID : iid , Staged : false , CreatedAt : time . Now ( ) . Unix ( ) , } return s . persist ( r ) }
Add marks c as fully-pinned by iid.
Add marks c as fully - pinned by iid .
// Log this situation since might be interesting.