Properly synchronised sqlite3 handler across threads
This commit is contained in:
parent
5b78da589e
commit
0afa1d2eaa
|
@ -30,8 +30,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- [2020-06-14] Removed old cache subdirectory migration system by [@carbotaniuman].
|
- [2020-06-14] Removed old cache subdirectory migration system by [@carbotaniuman].
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- [2020-06-15] Fixed tokenized data-saver parser not working by [@lflare].
|
|
||||||
- [2020-06-14] Switched cache metadata over to a MySql instance [@carbotaniuman].
|
- [2020-06-14] Switched cache metadata over to a MySql instance [@carbotaniuman].
|
||||||
|
- [2020-06-15] Fixed tokenized data-saver parser not working by [@lflare].
|
||||||
|
- [2020-06-15] Properly synchronised sqlite3 handler across threads by [@lflare].
|
||||||
|
|
||||||
## [1.0.0-RC16] - 2020-06-14
|
## [1.0.0-RC16] - 2020-06-14
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -77,8 +77,10 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi
|
||||||
val imageId = printHexString(rc4Bytes)
|
val imageId = printHexString(rc4Bytes)
|
||||||
|
|
||||||
val snapshot = cache.getUnsafe(imageId.toCacheId())
|
val snapshot = cache.getUnsafe(imageId.toCacheId())
|
||||||
val imageDatum = transaction(database) {
|
val imageDatum = synchronized(database) {
|
||||||
ImageDatum.findById(imageId)
|
transaction(database) {
|
||||||
|
ImageDatum.findById(imageId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot != null && imageDatum != null) {
|
if (snapshot != null && imageDatum != null) {
|
||||||
|
@ -96,8 +98,10 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi
|
||||||
if (LOGGER.isWarnEnabled) {
|
if (LOGGER.isWarnEnabled) {
|
||||||
LOGGER.warn("Deleting DB entry for $sanitizedUri without corresponding file")
|
LOGGER.warn("Deleting DB entry for $sanitizedUri without corresponding file")
|
||||||
}
|
}
|
||||||
transaction(database) {
|
synchronized(database) {
|
||||||
imageDatum.delete()
|
transaction(database) {
|
||||||
|
imageDatum.delete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,10 +178,12 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi
|
||||||
LOGGER.trace("Request for $sanitizedUri is being cached and served")
|
LOGGER.trace("Request for $sanitizedUri is being cached and served")
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction(database) {
|
synchronized(database) {
|
||||||
ImageDatum.new(imageId) {
|
transaction(database) {
|
||||||
this.contentType = contentType
|
ImageDatum.new(imageId) {
|
||||||
this.lastModified = lastModified
|
this.contentType = contentType
|
||||||
|
this.lastModified = lastModified
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue