mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
Never delete the install record while replacing it and clean the staging folder if marking fails
This commit is contained in:
3 files changed
+13
-3
No files matched your search
@@ -63,7 +63,7 @@ class StoreGameSidecar(
|
|||||||
val file = File(folder, FILE_NAME)
|
val file = File(folder, FILE_NAME)
|
||||||
val tmp = File(folder, "$FILE_NAME.tmp")
|
val tmp = File(folder, "$FILE_NAME.tmp")
|
||||||
tmp.writeText(toJson().toString(2))
|
tmp.writeText(toJson().toString(2))
|
||||||
if (!tmp.renameTo(file)) { file.delete(); tmp.renameTo(file) }
|
if (!tmp.renameTo(file)) java.nio.file.Files.move(tmp.toPath(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -30,7 +30,12 @@ object StoreInstalls {
|
|||||||
it.write(before.copy(state = StoreGameSidecar.STATE_UPDATING, installVersion = "").toJson().toString(2).toByteArray(Charsets.UTF_8))
|
it.write(before.copy(state = StoreGameSidecar.STATE_UPDATING, installVersion = "").toJson().toString(2).toByteArray(Charsets.UTF_8))
|
||||||
it.fd.sync()
|
it.fd.sync()
|
||||||
}
|
}
|
||||||
Files.move(stage.toPath(), StoreGameSidecar.file(folder).toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING)
|
val record = StoreGameSidecar.file(folder).toPath()
|
||||||
|
try {
|
||||||
|
Files.move(stage.toPath(), record, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
} catch (e: java.nio.file.AtomicMoveNotSupportedException) {
|
||||||
|
Files.move(stage.toPath(), record, StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
stage.delete()
|
stage.delete()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,7 +192,12 @@ internal class ItchInstaller(
|
|||||||
ItchStaging.delete(work)
|
ItchStaging.delete(work)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
StoreInstalls.markUpdating(folder)
|
try {
|
||||||
|
StoreInstalls.markUpdating(folder)
|
||||||
|
} catch (t: Throwable) {
|
||||||
|
ItchStaging.delete(work)
|
||||||
|
throw t
|
||||||
|
}
|
||||||
ItchStaging.merge(work, folder)
|
ItchStaging.merge(work, folder)
|
||||||
ItchStaging.delete(work)
|
ItchStaging.delete(work)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user