[VOL-3694] Previously generated mib-template in KV-store won't be regenerated if it was deleted manually

Change-Id: Ia1ae53ecdcdbaa29069ec76ebdeb1c382c751b84
diff --git a/VERSION b/VERSION
index f298681..7981294 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.15-dev148
+0.1.15-dev149
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/onuadaptercore/mib_sync.go
index 98e7704..dd1d25b 100644
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/onuadaptercore/mib_sync.go
@@ -195,8 +195,18 @@
 	} else {
 		logger.Debug(ctx, "MibSync FSM - no valid MEs stored from template - perform MIB-upload!")
 		fsmMsg = LoadMibTemplateFailed
-	}
 
+		oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
+		if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath]; exist {
+			if mibTemplateIsGenerated {
+				logger.Debugw(ctx,
+					"MibSync FSM - template was successfully generated before, but doesn't exist or isn't usable anymore - reset flag in map",
+					log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
+				oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
+			}
+		}
+		oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
+	}
 	mibSyncMsg := Message{
 		Type: TestMsg,
 		Data: TestMessage{