github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/app/subscription/subscriptionmanager/subdocchecker.go (about)

     1  package subscriptionmanager
     2  
     3  import "time"
     4  
     5  func (s *SubscriptionManagerImpl) checkupSubscription(subscriptionName string) error {
     6  	var trackedSub *trackedSubscription
     7  	if trackedSubFound, found := s.trackedSubscriptions[subscriptionName]; !found {
     8  		return newError("not found")
     9  	} else {
    10  		trackedSub = trackedSubFound
    11  	}
    12  
    13  	shouldUpdate := false
    14  
    15  	if trackedSub.currentDocumentExpireTime.Before(time.Now()) {
    16  		shouldUpdate = true
    17  	}
    18  
    19  	if shouldUpdate {
    20  		if err := s.updateSubscription(subscriptionName); err != nil {
    21  			return newError("failed to update subscription: ", err)
    22  		}
    23  	}
    24  
    25  	return nil
    26  }