@@ -167,25 +167,46 @@ trait JsonProvider[T <: Timestamped] extends ExternalPersistenceProvider[T] {
167167 } match {
168168 case Success (value) if value.uuid != uuid => // do nothing
169169 case Success (value) if value.uuid == uuid && value.state.isDefined || value.deleted =>
170- lastMatchingLine = value.state // return the state
170+ if (value.deleted){
171+ lastMatchingLine = None
172+ }
173+ else {
174+ lastMatchingLine = value.state // return the state
175+ }
171176 case _ =>
172- serialization.read[Map [String , Any ]](line).get(" state" ) match {
173- case Some (updated : Map [String , Any ]) =>
174- lastMatchingLine match {
175- case Some (l)
176- if updated
177- .get(" lastUpdated" )
178- .map(lu => Instant .parse(lu.toString))
179- .getOrElse(Instant .MIN )
180- .isAfter(l.lastUpdated) => // update the state
181- Try (updateCaseClass(l, updated)) match {
182- case Success (updated : T ) =>
183- lastMatchingLine = Some (updated)
177+ val parsed = serialization.read[Map [String , Any ]](line)
178+ val _uuid = parsed.get(" uuid" ) match {
179+ case Some (u : String ) => u
180+ case _ => " "
181+ }
182+ if (uuid == _uuid) {
183+ val deleted = parsed.get(" deleted" ) match {
184+ case Some (d) => d.toString.toBoolean
185+ case _ => false
186+ }
187+ if (deleted){
188+ lastMatchingLine = None
189+ }
190+ else {
191+ parsed.get(" state" ) match {
192+ case Some (updated : Map [String , Any ]) =>
193+ lastMatchingLine match {
194+ case Some (l)
195+ if updated
196+ .get(" lastUpdated" )
197+ .map(lu => Instant .parse(lu.toString))
198+ .getOrElse(Instant .MIN )
199+ .isAfter(l.lastUpdated) => // update the state
200+ Try (updateCaseClass(l, updated)) match {
201+ case Success (updated : T ) =>
202+ lastMatchingLine = Some (updated)
203+ case _ =>
204+ }
184205 case _ =>
185206 }
186207 case _ =>
187208 }
188- case _ =>
209+ }
189210 }
190211 }
191212 }
0 commit comments