Commit ef1b7cf4 authored by Szabolcs Gyurko's avatar Szabolcs Gyurko
Browse files

Added property to have a single SQLite thread in HikariCP. Removed unnecessary...

Added property to have a single SQLite thread in HikariCP. Removed unnecessary stuff from QueueManager actor. Fixed a bug where a return keyword was missing.
parent d673480a
......@@ -3,20 +3,14 @@ package actors
import javax.inject.{Inject, Singleton}
import akka.actor.UntypedActor
import entities.QueueTable
import play.api.Logger
import play.api.db.slick.DatabaseConfigProvider
import sget2.{JobFinishedEvent, SGet2}
import slick.driver.JdbcProfile
/**
* Created by sgyurko on 25/08/2016.
*/
@Singleton
class QueueManager @Inject() (private val dbConfigProvider: DatabaseConfigProvider, private val sget2: SGet2) extends UntypedActor {
private val dbConfig = dbConfigProvider.get[JdbcProfile]
import dbConfig.driver.api._
private val jobs = TableQuery[QueueTable]
class QueueManager @Inject() (private val sget2: SGet2) extends UntypedActor {
@scala.throws[Throwable](classOf[Throwable])
override def onReceive(message: Any): Unit = {
......
......@@ -108,7 +108,7 @@ class DownloadJob (private var _url: URL, private var _path: String)(implicit pr
* @return speed
*/
def speed(): (Double, Double) = {
if (status != DownloadJobStatusCode.STARTED) (0.0, 0.0)
if (status != DownloadJobStatusCode.STARTED) return (0.0, 0.0)
if (initialized()) {
val actualCheck = (System.currentTimeMillis(), chunkMatrix.downloaded)
......
......@@ -167,7 +167,7 @@ class DownloadQueue (private val sget2: SGet2, private val dbConfigProvider: Dat
private def getChunks(jobId: Int): Future[Seq[ChunkRecord]] = {
for {
c dbConfig.db.run(TableQuery[ChunksTable].filter(_.jobId === jobId).result)
c dbConfig.db.run(chunks.filter(_.jobId === jobId).result)
} yield c
}
}
name := "sget2"
version := "1.0"
version := "1.1"
lazy val `sget2` = (project in file(".")).enablePlugins(PlayScala)
......
......@@ -45,6 +45,7 @@ slick.dbs.default.db.url="jdbc:sqlite:sget2.db"
slick.dbs.default.db.url=${?DATABASE_URL}
slick.dbs.default.db.connectionInitSql="PRAGMA foreign_keys = ON"
slick.dbs.default.db.connectionTestQuery="select 1"
slick.dbs.default.db.numThreads=1
# Evolutions
# ~~~~~
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment