Browse Source

skip trial end date check on err

abhishek9686 1 year ago
parent
commit
32974e21d4
2 changed files with 8 additions and 6 deletions
  1. 7 5
      pro/initialize.go
  2. 1 1
      pro/trial.go

+ 7 - 5
pro/initialize.go

@@ -49,12 +49,14 @@ func InitPro() {
 			if err != nil {
 			if err != nil {
 				slog.Error("failed to get trial end date", "error", err)
 				slog.Error("failed to get trial end date", "error", err)
 				enableLicenseHook = true
 				enableLicenseHook = true
+			} else {
+				// check if trial ended
+				if time.Now().After(trialEndDate) {
+					// trial ended already
+					enableLicenseHook = true
+				}
 			}
 			}
-			// check if trial ended
-			if time.Now().After(trialEndDate) {
-				// trial ended already
-				enableLicenseHook = true
-			}
+
 		}
 		}
 
 
 		if enableLicenseHook {
 		if enableLicenseHook {

+ 1 - 1
pro/trial.go

@@ -46,7 +46,7 @@ func initTrial() error {
 		return err
 		return err
 	}
 	}
 	if telData.Hosts > 0 || telData.Networks > 0 || telData.Users > 0 {
 	if telData.Hosts > 0 || telData.Networks > 0 || telData.Users > 0 {
-		return nil
+		return nil // database is already populated, so skip creating trial
 	}
 	}
 	database.CreateTable(trial_table_name)
 	database.CreateTable(trial_table_name)
 	records, err := database.FetchRecords(trial_table_name)
 	records, err := database.FetchRecords(trial_table_name)