package com.github.nullptroma.wallenc.domain.vault.storages.local

import com.github.nullptroma.wallenc.domain.vault.storages.common.BaseStorage
import com.github.nullptroma.wallenc.domain.interfaces.IStorageAccessor
import kotlinx.coroutines.CoroutineDispatcher
import java.util.UUID

class LocalStorage(
    uuid: UUID,
    val absolutePath: String,
    ioDispatcher: CoroutineDispatcher,
) : BaseStorage(
    uuid = uuid,
    ioDispatcher = ioDispatcher,
    metaInfoFilePostfix = STORAGE_INFO_FILE_POSTFIX,
) {
    private val _accessor = LocalStorageAccessor(absolutePath, ioDispatcher)
    override val accessor: IStorageAccessor = _accessor
    override val isVirtualStorage: Boolean = false

    override suspend fun init() {
        _accessor.init()
        super.init()
    }

    companion object {
        const val STORAGE_INFO_FILE_POSTFIX = ".storage-info"
    }
}
