0.9.0
What's Changed
- Migrate to kotlinx-io by @mani1232 & @xxfast in #112 & #116
- Add transactions to file writes and restore files to previous state when transactions fail by @xxfast in #100
Add directories initialiser and tests by @xxfast in #132- Fix FileCodec by @forhad013 in #133
New Contributors
- @mani1232 made their first contribution in #112
- @forhad013 made their first contribution in #133
Full Changelog: 0.8.0...0.9.0
⚠️ Breaking Changes
- Bump kstore to
0.9.0
and removeokio
from your dependencies from yourlibs.version.toml
[versions]
- kstore = "0.8.0"
+ kstore = "0.9.0"
- okio = "3.6.0"
- If you are using
kstore-file
, migrate tokotlinx-io
'sPath
fromokio
's.toPath()
- import okio.Path.Companion.toPath
+ import kotlinx.io.files.Path
- val store: KStore<Pet> = storeOf(file = "saved.json".toPath())
+ val store: KStore<Pet> = storeOf(file = Path("saved.json"))
- On iOS - Remove the use of experimental
DocumentDirectory
API, and use NSFileManager directly
- val filesDir: String = NSFileManager.defaultManager.DocumentDirectory?.relativePath
+ val filesUrl: NSURL? = fileManager.URLForDirectory(
+ directory = NSDocumentDirectory,
+ appropriateForURL = null,
+ create = false,
+ inDomain = NSUserDomainMask,
+ error = null
+ )
+
+ val path: String = requireNotNull(filesUrl?.path) { "Documents directory not found" }
- val files = filesDirectory.toPath()
+ val files = Path(path)
- On Desktop - If you are using harawata/appdirs, make sure to create those directories if they don't already exist. The store won't create them for you
+ val filesDir: String = AppDirsFactory.getInstance()
+ .getUserDataDir("io.github.xxfast.nytimes", "1.0.0", "xxfast") // or whereever
+ val path = Path(filesDir)
+ with(SystemFileSystem) { if(!exists(path)) createDirectories(path) }
val store: KStore<Pet> = storeOf(file = path)