Улучшение UI/UX
This commit is contained in:
@@ -351,13 +351,18 @@ class EncryptedStorageAccessor(
|
||||
override suspend fun tryAcquireSyncLock(holderId: String, leaseUntil: Instant): Boolean {
|
||||
return syncLockMutex.withLock {
|
||||
val current = readSyncLock()
|
||||
if (current != null && current.holderId != holderId) {
|
||||
val now = Instant.now()
|
||||
val foreignLockActive = current != null &&
|
||||
current.holderId != holderId &&
|
||||
current.leaseUntil.isAfter(now) &&
|
||||
current.updatedAt.plusSeconds(SYNC_LOCK_STALE_TIMEOUT_SECONDS).isAfter(now)
|
||||
if (foreignLockActive) {
|
||||
return@withLock false
|
||||
}
|
||||
val next = StorageSyncLock(
|
||||
holderId = holderId,
|
||||
leaseUntil = leaseUntil,
|
||||
updatedAt = Instant.now(),
|
||||
updatedAt = now,
|
||||
)
|
||||
openWriteSystemFile(SYNC_LOCK_FILENAME).use { out ->
|
||||
jackson.writeValue(out, next)
|
||||
@@ -424,6 +429,7 @@ class EncryptedStorageAccessor(
|
||||
private companion object {
|
||||
private const val SYNC_JOURNAL_FILENAME = "sync-journal.json"
|
||||
private const val SYNC_LOCK_FILENAME = "sync-lock.json"
|
||||
private const val SYNC_LOCK_STALE_TIMEOUT_SECONDS: Long = 60 * 60
|
||||
private val jackson = com.fasterxml.jackson.module.kotlin.jacksonObjectMapper()
|
||||
.apply { findAndRegisterModules() }
|
||||
}
|
||||
|
||||
@@ -627,7 +627,12 @@ class LocalStorageAccessor(
|
||||
val fileLock = channel.lock()
|
||||
try {
|
||||
val current = readSyncLockFromChannel(channel)
|
||||
if (current != null && current.holderId != holderId) {
|
||||
val now = Instant.now()
|
||||
val foreignLockActive = current != null &&
|
||||
current.holderId != holderId &&
|
||||
current.leaseUntil.isAfter(now) &&
|
||||
current.updatedAt.plusSeconds(SYNC_LOCK_STALE_TIMEOUT_SECONDS).isAfter(now)
|
||||
if (foreignLockActive) {
|
||||
return@withContext false
|
||||
}
|
||||
|
||||
@@ -636,7 +641,7 @@ class LocalStorageAccessor(
|
||||
lock = StorageSyncLock(
|
||||
holderId = holderId,
|
||||
leaseUntil = leaseUntil,
|
||||
updatedAt = Instant.now(),
|
||||
updatedAt = now,
|
||||
),
|
||||
)
|
||||
return@withContext true
|
||||
@@ -742,6 +747,7 @@ class LocalStorageAccessor(
|
||||
private const val DATA_PAGE_LENGTH = 10
|
||||
private const val SYNC_JOURNAL_FILENAME = "sync-journal.json"
|
||||
private const val SYNC_LOCK_FILENAME = "sync-lock.json"
|
||||
private const val SYNC_LOCK_STALE_TIMEOUT_SECONDS: Long = 60 * 60
|
||||
private val jackson = jacksonObjectMapper().apply { findAndRegisterModules() }
|
||||
}
|
||||
}
|
||||
@@ -640,13 +640,18 @@ class YandexStorageAccessor(
|
||||
override suspend fun tryAcquireSyncLock(holderId: String, leaseUntil: Instant): Boolean = withContext(ioDispatcher) {
|
||||
return@withContext syncLockMutex.withLock {
|
||||
val current = readSyncLock()
|
||||
if (current != null && current.holderId != holderId) {
|
||||
val now = Instant.now()
|
||||
val foreignLockActive = current != null &&
|
||||
current.holderId != holderId &&
|
||||
current.leaseUntil.isAfter(now) &&
|
||||
current.updatedAt.plusSeconds(SYNC_LOCK_STALE_TIMEOUT_SECONDS).isAfter(now)
|
||||
if (foreignLockActive) {
|
||||
return@withLock false
|
||||
}
|
||||
val next = StorageSyncLock(
|
||||
holderId = holderId,
|
||||
leaseUntil = leaseUntil,
|
||||
updatedAt = Instant.now(),
|
||||
updatedAt = now,
|
||||
)
|
||||
openWriteSystemFile(SYNC_LOCK_FILENAME).use { out ->
|
||||
statsMapper.writeValue(out, next)
|
||||
@@ -716,6 +721,7 @@ class YandexStorageAccessor(
|
||||
private const val STATS_FILENAME = "yandex-vault-stats.json"
|
||||
private const val SYNC_JOURNAL_FILENAME = "sync-journal.json"
|
||||
private const val SYNC_LOCK_FILENAME = "sync-lock.json"
|
||||
private const val SYNC_LOCK_STALE_TIMEOUT_SECONDS: Long = 60 * 60
|
||||
private const val STATS_DEBOUNCE_MS = 450L
|
||||
private const val DATA_PAGE_LENGTH = 10
|
||||
private const val API_LIST_LIMIT = 1000
|
||||
|
||||
Reference in New Issue
Block a user