Skip to content

Commit 0a4f137

Browse files
committed
fallback to copy if resources rename fails
1 parent 3cb0998 commit 0a4f137

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

app/src/main/java/com/geode/launcher/updater/ReleaseManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ class ReleaseManager private constructor(
206206
}
207207

208208
if (!outputDir.renameTo(finalDir)) {
209-
throw IOException("failed to rename resources output directory")
209+
println("Failed to rename temporary directory!")
210+
DownloadUtils.copyDirectory(outputDir, finalDir)
210211
}
211212
}
212213
)

app/src/main/java/com/geode/launcher/utils/DownloadUtils.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ object DownloadUtils {
160160
}}
161161
}
162162
}
163+
164+
suspend fun copyDirectory(sourceFile: File, outputFile: File) = withContext(Dispatchers.IO) {
165+
sourceFile.copyRecursively(
166+
outputFile,
167+
overwrite = true
168+
)
169+
}
163170
}
164171

165172
// based on <https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/Progress.java>

0 commit comments

Comments
 (0)