Fix for 15671

Snapshot files were being retrieved based on the persistenceId appearing in the *start* of their filenames.

Changed this to break down the filename, extract the full persistenceId in it, and compare for equality. I've tested this locally and it seems to work. There were no suitable unit tests to update, that I could see.
Makes sense. I'll do that now.


On Tue, Aug 19, 2014 at 5:59 PM, Konrad Malawski <notifications@github.com>
wrote:

> In
> akka-persistence/src/main/scala/akka/persistence/snapshot/local/LocalSnapshotStore.scala:
>
> > @@ -120,6 +120,9 @@ private[persistence] class LocalSnapshotStore extends SnapshotStore with ActorLo
> >    }
> >
> >    private class SnapshotFilenameFilter(persistenceId: String) extends FilenameFilter {
> > -    def accept(dir: File, name: String): Boolean = name.startsWith(s"snapshot-${URLEncoder.encode(persistenceId, "UTF-8")}")
> > +    def accept(dir: File, name: String): Boolean = {
> > +      val persistenceIdInFileName = name.split("-").drop(1).dropRight(2) mkString ("-")
>
> Yeap, but instead of "magic drops" let's use the FilenamePattern from line
> 27:
>
> private val FilenamePattern = """^snapshot-(.+)-(\d+)-(\d+)""".r
>
> if you would pattern match on the name here like on line 109 in this file
> it would be much less error prone.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/akka/akka/pull/15691/files#r16424350>.
>