feat(yandex-disk): REST client, repository, and app-folder storages

Add Yandex Disk API (Retrofit + OkHttp), per-vault repository with DB-backed
OAuth token, YandexStorage/YandexStorageAccessor under app:/<uuid>, and a
real YandexVault bootstrap (disk quota, list storages, create/remove).

Expose vault and storage availability: vault is reachable after diskInfo;
each storage combines vault reachability with local init readiness. Map
401 to YandexDiskAuthException and mark the vault unavailable.

Add YandexAccountDao.getByVaultUuid for fresh tokens on each request.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-03 21:11:53 +03:00
parent d60cd9053a
commit be1ba29f4d
13 changed files with 1048 additions and 14 deletions

View File

@@ -8,6 +8,8 @@ import com.github.nullptroma.wallenc.data.db.app.dao.YandexAccountDao
import com.github.nullptroma.wallenc.data.db.app.repository.StorageKeyMapRepository
import com.github.nullptroma.wallenc.data.db.app.repository.StorageMetaInfoRepository
import com.github.nullptroma.wallenc.data.db.app.repository.YandexAccountRepository
import com.github.nullptroma.wallenc.data.network.yandexdisk.YandexDiskApiFactory
import com.github.nullptroma.wallenc.data.network.yandexdisk.repository.YandexDiskRepositoryFactory
import com.github.nullptroma.wallenc.data.network.yandexuserinfo.YandexUserInfoApi
import com.github.nullptroma.wallenc.data.network.yandexuserinfo.YandexUserInfoApiFactory
import com.github.nullptroma.wallenc.data.network.yandexuserinfo.repository.YandexUserInfoRepository
@@ -38,6 +40,26 @@ class SingletonModule {
@Singleton
fun provideYandexUserInfoApi(): YandexUserInfoApi = YandexUserInfoApiFactory.create()
@Provides
@Singleton
fun provideYandexDiskApiFactory(
yandexAccountRepository: YandexAccountRepository,
@IoDispatcher ioDispatcher: CoroutineDispatcher,
): YandexDiskApiFactory = YandexDiskApiFactory(
accountRepository = yandexAccountRepository,
ioDispatcher = ioDispatcher,
)
@Provides
@Singleton
fun provideYandexDiskRepositoryFactory(
apiFactory: YandexDiskApiFactory,
@IoDispatcher ioDispatcher: CoroutineDispatcher,
): YandexDiskRepositoryFactory = YandexDiskRepositoryFactory(
apiFactory = apiFactory,
ioDispatcher = ioDispatcher,
)
@Provides
@Singleton
fun provideVaultsManager(
@@ -46,6 +68,7 @@ class SingletonModule {
keyRepo: StorageKeyMapRepository,
yandexAccountRepository: YandexAccountRepository,
yandexUserInfoRepository: YandexUserInfoRepository,
yandexDiskRepositoryFactory: YandexDiskRepositoryFactory,
): VaultsManager {
return VaultsManager(
ioDispatcher = ioDispatcher,
@@ -53,6 +76,7 @@ class SingletonModule {
keyRepo = keyRepo,
yandexAccountRepository = yandexAccountRepository,
yandexUserInfoRepository = yandexUserInfoRepository,
yandexDiskRepositoryFactory = yandexDiskRepositoryFactory,
)
}