@@ -21,10 +21,11 @@ import net.syncthing.java.core.beans.DeviceAddress
21
21
import net.syncthing.java.core.beans.DeviceId
22
22
import net.syncthing.java.core.beans.DeviceInfo
23
23
import net.syncthing.java.core.configuration.Configuration
24
+ import net.syncthing.java.core.interfaces.IndexRepository
25
+ import net.syncthing.java.core.interfaces.TempRepository
24
26
import net.syncthing.java.core.security.KeystoreHandler
25
27
import net.syncthing.java.core.utils.awaitTerminationSafe
26
28
import net.syncthing.java.discovery.DiscoveryHandler
27
- import net.syncthing.java.repository.repo.SqlRepository
28
29
import org.slf4j.LoggerFactory
29
30
import java.io.Closeable
30
31
import java.io.IOException
@@ -35,11 +36,14 @@ import java.util.concurrent.TimeUnit
35
36
import java.util.concurrent.atomic.AtomicBoolean
36
37
import kotlin.collections.ArrayList
37
38
38
- class SyncthingClient (private val configuration : Configuration ) : Closeable {
39
+ class SyncthingClient (
40
+ private val configuration : Configuration ,
41
+ private val repository : IndexRepository ,
42
+ private val tempRepository : TempRepository
43
+ ) : Closeable {
39
44
40
45
private val logger = LoggerFactory .getLogger(javaClass)
41
46
val discoveryHandler: DiscoveryHandler
42
- private val sqlRepository = SqlRepository (configuration.databaseFolder)
43
47
val indexHandler: IndexHandler
44
48
private val connections = Collections .synchronizedSet(createConnectionsSet())
45
49
private val connectByDeviceIdLocks = Collections .synchronizedMap(HashMap <DeviceId , Object >())
@@ -49,7 +53,7 @@ class SyncthingClient(private val configuration: Configuration) : Closeable {
49
53
private fun createConnectionsSet () = TreeSet <ConnectionHandler >(compareBy { it.address.score })
50
54
51
55
init {
52
- indexHandler = IndexHandler (configuration, sqlRepository, sqlRepository )
56
+ indexHandler = IndexHandler (configuration, repository, tempRepository )
53
57
discoveryHandler = DiscoveryHandler (configuration)
54
58
connectDevicesScheduler.scheduleAtFixedRate(this ::updateIndexFromPeers, 0 , 15 , TimeUnit .SECONDS )
55
59
}
@@ -219,7 +223,8 @@ class SyncthingClient(private val configuration: Configuration) : Closeable {
219
223
// Create copy of list, because it will be modified by handleConnectionClosedEvent(), causing ConcurrentModificationException.
220
224
ArrayList (connections).forEach{it.close()}
221
225
indexHandler.close()
222
- sqlRepository.close()
226
+ repository.close()
227
+ tempRepository.close()
223
228
assert (onConnectionChangedListeners.isEmpty())
224
229
}
225
230
0 commit comments