Skip to content

refactor: replace kotlinx-io with okio for file I/O#123

Merged
linroid merged 5 commits intomainfrom
refactor/replace-kotlinx-io-with-okio
Feb 26, 2026
Merged

refactor: replace kotlinx-io with okio for file I/O#123
linroid merged 5 commits intomainfrom
refactor/replace-kotlinx-io-with-okio

Conversation

@linroid
Copy link
Owner

@linroid linroid commented Feb 26, 2026

Okio provides a unified cross-platform FileHandle API with built-in random access support (positional read/write, flush, resize), eliminating the need for the RandomAccessHandle abstraction and its per-platform implementations (JvmRandomAccessHandle, IosRandomAccessHandle).

  • Replace kotlinx-io 0.9.0 with okio 3.16.4 across all modules
  • Delete RandomAccessHandle interface and JVM/Android/iOS implementations
  • Rewrite PathFileAccessor to use okio FileHandle (openReadWrite)
  • Add platformFileSystem expect/actual to abstract FileSystem.SYSTEM (unavailable on WasmJs; throws UnsupportedOperationException there)
  • Simplify createFileAccessor on JVM/iOS (no more handleFactory param)
  • Update resolveChildPath to use okio Path division operator
  • Update DownloadExecution.deduplicatePath to use okio Path/FileSystem
  • Update FileConfigStore to use okio source/sink/buffer APIs
  • Remove unused kotlinx-io dependency from library:sqlite
  • Update GraalVM --initialize-at-build-time from kotlinx.io to okio

Okio provides a unified cross-platform FileHandle API with built-in
random access support (positional read/write, flush, resize), eliminating
the need for the RandomAccessHandle abstraction and its per-platform
implementations (JvmRandomAccessHandle, IosRandomAccessHandle).

- Replace kotlinx-io 0.9.0 with okio 3.16.4 across all modules
- Delete RandomAccessHandle interface and JVM/Android/iOS implementations
- Rewrite PathFileAccessor to use okio FileHandle (openReadWrite)
- Add platformFileSystem expect/actual to abstract FileSystem.SYSTEM
  (unavailable on WasmJs; throws UnsupportedOperationException there)
- Simplify createFileAccessor on JVM/iOS (no more handleFactory param)
- Update resolveChildPath to use okio Path division operator
- Update DownloadExecution.deduplicatePath to use okio Path/FileSystem
- Update FileConfigStore to use okio source/sink/buffer APIs
- Remove unused kotlinx-io dependency from library:sqlite
- Update GraalVM --initialize-at-build-time from kotlinx.io to okio
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

Test Results

1 045 tests   - 76   1 045 ✅  - 76   14s ⏱️ -1s
   94 suites  -  4       0 💤 ± 0 
   94 files    -  4       0 ❌ ± 0 

Results for commit 59e3681. ± Comparison against base commit 2c1ae06.

This pull request removes 350 and adds 274 tests. Note that renamed tests count towards both.
wasmJsBrowserTest.com.linroid.ketch.api.DownloadPriorityTest ‑ ordinal_ordering[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ isComplete_whenFullyDownloaded[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ isComplete_whenOverDownloaded[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ isNotComplete_whenPartial[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ isNotComplete_whenZeroTotal[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ percent_complete[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ percent_halfComplete[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ percent_zeroProgress[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadProgressTest ‑ percent_zeroTotal_returnsZero[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
wasmJsBrowserTest.com.linroid.ketch.api.DownloadRequestTest ‑ blankUrl_throws[wasmJs, browser, ChromeHeadless145.0.0.0, Linux0.0.0]
…
jsNodeTest.com.linroid.ketch.DownloadConfigTest ‑ invalidMaxSegments_throws[js, node]
jsNodeTest.com.linroid.ketch.DownloadConfigTest ‑ negativeMaxConcurrentDownloads_throws[js, node]
jsNodeTest.com.linroid.ketch.DownloadConfigTest ‑ negativeMaxConnectionsPerHost_throws[js, node]
jsNodeTest.com.linroid.ketch.DownloadConfigTest ‑ negativeRetryCount_throws[js, node]
jsNodeTest.com.linroid.ketch.DownloadConfigTest ‑ negativeRetryDelay_throws[js, node]
jsNodeTest.com.linroid.ketch.DownloadConfigTest ‑ zeroBufferSize_throws[js, node]
jsNodeTest.com.linroid.ketch.DownloadConfigTest ‑ zeroProgressInterval_throws[js, node]
jsNodeTest.com.linroid.ketch.api.DownloadPriorityTest ‑ ordinal_ordering[js, node]
jsNodeTest.com.linroid.ketch.api.DownloadProgressTest ‑ isComplete_whenFullyDownloaded[js, node]
jsNodeTest.com.linroid.ketch.api.DownloadProgressTest ‑ isComplete_whenOverDownloaded[js, node]
…

♻️ This comment has been updated with latest results.

Replace wasmJs with js target in library:api and library:core to
enable okio-nodefilesystem (NodeJsFileSystem) for Kotlin/JS. Add
wasmWasi target with okio-wasifilesystem (WasiFileSystem) for WASI
runtimes. Remove wasmJs from these modules since app/web (the only
wasmJs consumer) only uses RemoteKetch and doesn't need core/api.
The wasmJs target was replaced with js in library modules, so the
wasmJsBrowserTest/wasmJsNodeTest Gradle tasks no longer exist.
InstanceFactory no longer references library:core types (Ketch,
DownloadSource, TaskStore, KtorHttpEngine). Instead, each platform
(Android, Desktop, iOS) creates the embedded Ketch instance inline
and passes it as an embeddedFactory lambda.

This removes the library:core dependency from app:shared's commonMain,
allowing wasmJs builds to work without the core engine. Also restores
wasmJs target on library:api since downstream modules still need it.
@linroid linroid merged commit ea01275 into main Feb 26, 2026
6 checks passed
@linroid linroid deleted the refactor/replace-kotlinx-io-with-okio branch February 26, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant