mirror of
https://gitlab.com/mangadex-pub/mangadex_at_home.git
synced 2024-11-17 00:22:32 +01:00
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].
|
||||
|
||||
### 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-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
|
||||
### Added
|
||||
|
@ -77,8 +77,10 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi
|
||||
val imageId = printHexString(rc4Bytes)
|
||||
|
||||
val snapshot = cache.getUnsafe(imageId.toCacheId())
|
||||
val imageDatum = transaction(database) {
|
||||
ImageDatum.findById(imageId)
|
||||
val imageDatum = synchronized(database) {
|
||||
transaction(database) {
|
||||
ImageDatum.findById(imageId)
|
||||
}
|
||||
}
|
||||
|
||||
if (snapshot != null && imageDatum != null) {
|
||||
@ -96,8 +98,10 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi
|
||||
if (LOGGER.isWarnEnabled) {
|
||||
LOGGER.warn("Deleting DB entry for $sanitizedUri without corresponding file")
|
||||
}
|
||||
transaction(database) {
|
||||
imageDatum.delete()
|
||||
synchronized(database) {
|
||||
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")
|
||||
}
|
||||
|
||||
transaction(database) {
|
||||
ImageDatum.new(imageId) {
|
||||
this.contentType = contentType
|
||||
this.lastModified = lastModified
|
||||
synchronized(database) {
|
||||
transaction(database) {
|
||||
ImageDatum.new(imageId) {
|
||||
this.contentType = contentType
|
||||
this.lastModified = lastModified
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user