// persist persists a PinnedCid in the datastore.
persist persists a PinnedCid in the datastore.
// persist persists a PinnedCid in the datastore .
func (s *Store) persist(r PinnedCid) error {
	k := makeKey(r.Cid)
	if len(r.Pins) == 0 {
		if err := s.ds.Delete(k); err != nil {
			return fmt.Errorf("delete from datastore: %s", err)
		}
		delete(s.cache, r.Cid)
		return nil
	}
	buf, err := json.Marshal(r)
	if err != nil {
		return fmt.Errorf("marshaling to datastore: %s", err)
	}
	if err := s.ds.Put(k, buf); err != nil {
		return fmt.Errorf("put in datastore: %s", err)
	}
	s.cache[r.Cid] = r
	return nil
}
func ( s * Store ) persist ( r PinnedCid ) error { k := makeKey ( r . Cid ) if len ( r . Pins ) == 0 { if err := s . ds . Delete ( k ) ; err != nil { return fmt . Errorf ( " " , err ) } delete ( s . cache , r . Cid ) return nil } buf , err := json . Marshal ( r ) if err != nil { return fmt . Errorf ( " " , err ) } if err := s . ds . Put ( k , buf ) ; err != nil { return fmt . Errorf ( " " , err ) } s . cache [ r . Cid ] = r return nil }
persist persists a PinnedCid in the datastore.
persist persists a PinnedCid in the datastore .