mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
An ending session takes its log folder with it; the session replacing it gets its own
Handing off from the desktop, the new session claimed the folder the desktop was still finishing, and the desktop's collector then stopped the new session's app.log capture. The folder is taken from the shared slot as the session stops and handed to its collector; the next session's beginOrCurrent finds the slot empty and makes a new folder.
This commit is contained in:
1 parent
68b09c1ed1
commit
d39fd02d04
2 files changed
+18
-7
No files matched your search
@@ -51,16 +51,27 @@ object SessionPaths {
|
||||
/** The current session's folder, or null between sessions. */
|
||||
fun current(): File? = dir
|
||||
|
||||
/**
|
||||
* The ending session takes its folder with it: the next session (one that replaces this one
|
||||
* in place) then claims a folder of its own instead of sharing, and this one's collector
|
||||
* finishes the folder it was handed. Called on the main thread as the session stops.
|
||||
*/
|
||||
@Synchronized
|
||||
fun take(): File? {
|
||||
val ended = dir
|
||||
dir = null
|
||||
return ended
|
||||
}
|
||||
|
||||
/** A file in the current session's folder, or null between sessions. */
|
||||
fun file(name: String): File? = dir?.let { File(it, name) }
|
||||
|
||||
/** Let the next session claim a new folder. Called when a session ends. */
|
||||
@Synchronized
|
||||
fun release(context: Context, ended: File) {
|
||||
// Only the session that owns the folder lets go of it: the next session may have claimed
|
||||
// its own by the time the last one's collecting thread gets here.
|
||||
if (dir != ended) return
|
||||
dir = null
|
||||
// Only the session that owns the folder lets go of it (take() usually has already): the
|
||||
// next session may have claimed its own by the time the last one's collector gets here.
|
||||
if (dir == ended) dir = null
|
||||
// A folder kept in the cache was never meant to outlive its session.
|
||||
if (ended != null && ended.path.startsWith(context.cacheDir.path)) {
|
||||
com.steamdeck.launcher.core.FileUtils.delete(ended)
|
||||
|
||||
@@ -99,8 +99,7 @@ class SessionService : Service() {
|
||||
* which is when they matter. The collecting itself is [SessionArtifacts], shared with the
|
||||
* crash handler and the next-start sweep so a folder is finished whichever way it ends.
|
||||
*/
|
||||
private fun collectSessionArtifacts() {
|
||||
val dir = SessionPaths.current() ?: return
|
||||
private fun collectSessionArtifacts(dir: File) {
|
||||
try {
|
||||
SessionArtifacts.collect(this, dir, "session stopped")
|
||||
} finally {
|
||||
@@ -554,7 +553,8 @@ class SessionService : Service() {
|
||||
// every Steam log line by line - 42 files on one measured run - and waiting for logcat to
|
||||
// dump the crash buffer. That was about four and a half seconds of blocked main thread,
|
||||
// and Android ANR'd the app for it: the desktop session that would not let go.
|
||||
Thread({ collectSessionArtifacts() }, "session-collect").start()
|
||||
val ended = SessionPaths.take()
|
||||
if (ended != null) Thread({ collectSessionArtifacts(ended) }, "session-collect").start()
|
||||
components.reversed().forEach {
|
||||
try {
|
||||
it.stop()
|
||||
|
||||
Reference in new issue
Block a user