Skip to content

Commit

Permalink
fix(sde): adapt to changes in the equinox expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
updraft0 committed Jun 11, 2024
1 parent 1757c22 commit aafd41a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.snakeyaml.engine.v2.api.LoadSettings
*/
object parser:

private val RegionData = """sde/fsd/universe/\w+/([-\w]+)/region.staticdata""".r
private val ConstellationData = """sde/fsd/universe/\w+/([-\w]+)/([-\w]+)/constellation.staticdata""".r
private val SolarSystemData = """sde/fsd/universe/\w+/([-\w]+)/([-\w]+)/([-\w]+)/solarsystem.staticdata""".r
private val RegionData = """universe/\w+/([-\w]+)/region.yaml""".r
private val ConstellationData = """universe/\w+/([-\w]+)/([-\w]+)/constellation.yaml""".r
private val SolarSystemData = """universe/\w+/([-\w]+)/([-\w]+)/([-\w]+)/solarsystem.yaml""".r

private type Parser[T] = IO[Error, T]

Expand All @@ -24,27 +24,27 @@ object parser:
def parse(entry: zip.ZipEntry): ZIO[LoadSettings, Error, Option[ExportedData]] = {
val bytes = entry.bytes
ZIO.logTrace(s"parsing entry ${entry.name}") *> (entry.name match {
case "sde/bsd/invUniqueNames.yaml" =>
case "bsd/invUniqueNames.yaml" =>
parseYamlArray(bytes).flatMap(parseUniqueNames).asSome
case "sde/fsd/categoryIDs.yaml" =>
case "fsd/categories.yaml" =>
parseYaml[Integer](bytes).flatMap(parseCategoryIds).asSome
case "sde/fsd/dogmaAttributeCategories.yaml" =>
case "fsd/dogmaAttributeCategories.yaml" =>
parseYaml[Integer](bytes).flatMap(parseDogmaAttributeCategories).asSome
case "sde/fsd/dogmaAttributes.yaml" =>
case "fsd/dogmaAttributes.yaml" =>
parseYaml[Integer](bytes).flatMap(parseDogmaAttributes).asSome
case "sde/fsd/factions.yaml" =>
case "fsd/factions.yaml" =>
parseYaml[Integer](bytes).flatMap(parseFactions).asSome
case "sde/fsd/npcCorporations.yaml" =>
case "fsd/npcCorporations.yaml" =>
parseYaml[Integer](bytes).flatMap(parseNpcCorporations).asSome
case "sde/fsd/groupIDs.yaml" =>
case "fsd/groups.yaml" =>
parseYaml[Integer](bytes).flatMap(parseGroupIds).asSome
case "sde/fsd/stationOperations.yaml" =>
case "fsd/stationOperations.yaml" =>
parseYaml[Integer](bytes).flatMap(parseStationOperations).asSome
case "sde/fsd/stationServices.yaml" =>
case "fsd/stationServices.yaml" =>
parseYaml[Integer](bytes).flatMap(parseStationServices).asSome
case "sde/fsd/typeDogma.yaml" =>
case "fsd/typeDogma.yaml" =>
parseYaml[Integer](bytes).flatMap(parseTypeDogmas).asSome
case "sde/fsd/typeIDs.yaml" =>
case "fsd/types.yaml" =>
parseYaml[Integer](bytes).flatMap(parseTypeIds).asSome
case RegionData(regionName) =>
parseYaml[String](bytes).flatMap(parseRegion(regionName, _)).asSome
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ def updateReferenceData =
/** Load while checking if up to date
*/
private[server] def checkSdeAndReload(): RIO[SdeConfig & DataSource & SdeClient, (Int, Chunk[Long])] =
(query.transaction(query.sde.getLatestVersion) <&> ZIO.serviceWithZIO[SdeClient](_.latestChecksum)).flatMap:
(query.transaction(query.sde.getLatestVersion) <&> loadSdeZipChecksum).flatMap:
case (None, checksum) => ZIO.logInfo("SDE not loaded, loading") *> loadSde(checksum)
case (Some(version), checksum) if version.meta.checksum == checksum =>
ZIO.logInfo(s"SDE up to date with ${version}").as(version.id -> Chunk.empty)
case (Some(version), checksum) =>
ZIO.logInfo(s"SDE checksum changed from ${version.meta.checksum} to ${checksum}, updating") *> loadSde(checksum)

// checksums contains a newline-delimited list of checksums and we got to find the one for sde.zip
private def loadSdeZipChecksum =
ZIO
.serviceWithZIO[SdeClient](_.latestChecksum)
.map(_.linesIterator.filter(_.endsWith("sde.zip")).map(_.split("""\s""")(0)).next())

// TODO: add query.transaction() here
private[server] def loadSde(checksum: String): RIO[SdeConfig & DataSource & SdeClient, (Int, Chunk[Long])] =
for
Expand Down

0 comments on commit aafd41a

Please sign in to comment.