Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Karasiq committed Jul 21, 2020
1 parent 6ab5321 commit 7fe3d10
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ object SCDesktopMain extends App {

val sc = ShadowCloud(actorSystem)

import sc.implicits.executionContext

sc.init()

val httpServer = SCAkkaHttpServer(sc)
Expand Down
10 changes: 10 additions & 0 deletions drive/fuse/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ shadowcloud.drive.fuse {

fix-utf8 = true
}

default-dispatcher {
type = Dispatcher
executor = fork-join-executor

fork-join-executor {
parallelism-min = 2
parallelism-max = 16
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package com.karasiq.shadowcloud.drive.fuse
import java.nio.file.Paths

import akka.Done
import akka.actor.ActorRef
import akka.event.LoggingAdapter
import akka.actor.{ActorRef, ActorSystem}
import akka.event.Logging
import akka.pattern.ask
import akka.util.{ByteString, Timeout}
import com.karasiq.common.configs.ConfigImplicits._
import com.karasiq.common.configs.ConfigUtils
import com.karasiq.shadowcloud.ShadowCloud
import com.karasiq.shadowcloud.actors.utils.MessageStatus
import com.karasiq.shadowcloud.drive.FileIOScheduler
import com.karasiq.shadowcloud.drive.config.SCDriveConfig
Expand All @@ -28,8 +29,8 @@ import scala.util.control.NonFatal
import scala.util.{Failure, Success, Try}

object SCFileSystem {
def apply(config: SCDriveConfig, fsDispatcher: ActorRef, log: LoggingAdapter)(implicit ec: ExecutionContext): SCFileSystem = {
new SCFileSystem(config, fsDispatcher, log)
def apply(config: SCDriveConfig, fsDispatcher: ActorRef, actorSystem: ActorSystem)(implicit ec: ExecutionContext): SCFileSystem = {
new SCFileSystem(config, fsDispatcher, actorSystem)
}

def getMountPath(config: Config = ConfigUtils.emptyConfig): String = {
Expand Down Expand Up @@ -69,14 +70,17 @@ object SCFileSystem {
}
}

class SCFileSystem(config: SCDriveConfig, fsDispatcher: ActorRef, log: LoggingAdapter)(implicit ec: ExecutionContext) extends FuseStubFS {
class SCFileSystem(config: SCDriveConfig, fsDispatcher: ActorRef, actorSystem: ActorSystem)(implicit ec: ExecutionContext) extends FuseStubFS {
protected final case class FileHandle(handle: Long, file: File)

import SCFileSystem.implicitStrToPath
import com.karasiq.shadowcloud.drive.VirtualFSDispatcher._

protected implicit val timeout = Timeout(config.fileIO.readTimeout)
protected val writeTimeout = Timeout(config.fileIO.writeTimeout)
protected val log = Logging(actorSystem, "SCFileSystem")

protected implicit lazy val timeout = Timeout(ShadowCloud(actorSystem).config.timeouts.query)
protected val readTimeout = Timeout(config.fileIO.readTimeout)
protected val writeTimeout = Timeout(config.fileIO.writeTimeout)

protected object settings {
val fuseConfig = config.rootConfig.getConfigIfExists("fuse")
Expand Down Expand Up @@ -235,7 +239,7 @@ class SCFileSystem(config: SCDriveConfig, fsDispatcher: ActorRef, log: LoggingAd
DispatchIOOperation,
critical = true,
handle = fi.fh.longValue()
)
)(readTimeout)
)

result match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import java.nio.file.{Files, Paths}

import akka.Done
import akka.actor.ActorSystem
import akka.event.Logging
import com.karasiq.shadowcloud.ShadowCloudExtension
import com.karasiq.shadowcloud.drive.SCDrive

import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.Future

object SCFuseHelper {
def mount()(implicit actorSystem: ActorSystem, ec: ExecutionContext): Future[Done] = {
def mount()(implicit actorSystem: ActorSystem): Future[Done] = {
import com.karasiq.common.configs.ConfigImplicits._

// Init FUSE file system
val drive = SCDrive(actorSystem)
val fuseConfig = drive.config.rootConfig.getConfigIfExists("fuse")
val drive = SCDrive(actorSystem)
val fuseConfig = drive.config.rootConfig.getConfigIfExists("fuse")
implicit val dispatcher = actorSystem.dispatchers.lookup("shadowcloud.drive.fuse.default-dispatcher")

// Fix FUSE properties
val fuseWinFspDll = {
Expand All @@ -29,7 +28,7 @@ object SCFuseHelper {
System.setProperty("file.encoding", "UTF-8")
}

val fileSystem = SCFileSystem(drive.config, drive.dispatcher, Logging(actorSystem, "SCFileSystem"))
val fileSystem = SCFileSystem(drive.config, drive.dispatcher, actorSystem)
val mountFuture = SCFileSystem.mountInSeparateThread(fileSystem)
mountFuture.failed.foreach(actorSystem.log.error(_, "FUSE filesystem mount failed"))
sys.addShutdownHook(fileSystem.umount())
Expand Down
6 changes: 5 additions & 1 deletion larray-bytestring/src/main/scala/akka/util/ByteString.scala
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
_builder ++= bs.bytestrings
_length += bs.length
case xs: WrappedArray.ofByte
putByteArrayUnsafe(BSLArray.toLArray(xs.array))
putByteArrayUnsafe(xs.array)
case seq: collection.IndexedSeq[Byte] if shouldResizeTempFor(seq.length)
val copied = new Array[Byte](seq.length)
seq.copyToArray(copied)
Expand Down Expand Up @@ -1016,6 +1016,10 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
this
}

private[akka] def putByteArrayUnsafe(xs: Array[Byte]): this.type = {
putByteArrayUnsafe(BSLArray.toLArray(xs))
}

/**
* Java API: append a ByteString to this builder.
*/
Expand Down
3 changes: 2 additions & 1 deletion metadata/tika/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ shadowcloud.metadata {
m4a
m4b

// Misc
// Databases
db
sqlite
]
mimes = []

Expand Down

0 comments on commit 7fe3d10

Please sign in to comment.