Skip to content

Commit

Permalink
fix: work with the old synced asset files hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed May 10, 2024
1 parent e84a7ae commit 46cd745
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/osfans/trime/data/base/DataManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ object DataManager {
when (it) {
is DataDiff.CreateFile,
is DataDiff.UpdateFile,
-> ResourceUtils.copyFile(it.path, sharedDataDir)
-> ResourceUtils.copyFile(it.path, sharedDataDir, "rime/")
is DataDiff.DeleteDir,
is DataDiff.DeleteFile,
-> FileUtils.delete(sharedDataDir.resolve(it.path)).getOrThrow()
-> FileUtils.delete(sharedDataDir.resolve(it.path.removePrefix("rime/"))).getOrThrow()
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/osfans/trime/util/ResourceUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ object ResourceUtils {
fun copyFile(
filename: String,
dest: File,
removedPrefix: String = "",
) = runCatching {
appContext.assets.open(filename).use { i ->
File(dest, filename)
File(dest, filename.removePrefix(removedPrefix))
.also { it.parentFile?.mkdirs() }
.outputStream()
.use { o -> i.copyTo(o) }
Expand Down

0 comments on commit 46cd745

Please sign in to comment.