Skip to content

Commit 85aa676

Browse files
committed
chore: remove unused UPLOADED and EXPIRED session states
Both enum values were dead writes — no code path ever assigned them. The defensive reads in isExpired() and terminateSession() collapse cleanly: ABORTED is the only terminal that suppresses quota release, and time-based expiry is computed live from the timestamp fields rather than persisted via a state mutation. Re-adding either case is a 5-minute change if a future status-polling endpoint wants to surface session-expired or finalize-in-flight as observable states.
1 parent dae7a16 commit 85aa676

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/main/kotlin/eu/darken/octi/server/module/UploadSessionMeta.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ data class UploadSessionMeta(
2828
val state: State,
2929
) {
3030
@Serializable
31-
enum class State { ACTIVE, UPLOADED, COMPLETE, ABORTED, EXPIRED }
31+
enum class State { ACTIVE, COMPLETE, ABORTED }
3232

3333
fun isExpired(now: Instant = Instant.now()): Boolean {
34-
if (state == State.ABORTED || state == State.EXPIRED) return true
34+
if (state == State.ABORTED) return true
3535
// Absolute expiry
3636
if (now.isAfter(expiresAt)) return true
3737
// Idle expiry

src/main/kotlin/eu/darken/octi/server/module/UploadSessionRepo.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class UploadSessionRepo @Inject constructor(
257257
return@withLock FinalizeResult.AlreadyComplete(meta.blobId, meta.expectedSizeBytes)
258258
}
259259

260-
if (meta.state != UploadSessionMeta.State.ACTIVE && meta.state != UploadSessionMeta.State.UPLOADED) {
260+
if (meta.state != UploadSessionMeta.State.ACTIVE) {
261261
return@withLock FinalizeResult.SessionNotFound
262262
}
263263

@@ -333,7 +333,7 @@ class UploadSessionRepo @Inject constructor(
333333
} catch (e: Exception) {
334334
log(TAG, WARN) { "terminateSession(${meta.sessionId}): failed to delete dir: ${e.message}" }
335335
}
336-
if (meta.expectedSizeBytes > 0 && meta.state != UploadSessionMeta.State.ABORTED && meta.state != UploadSessionMeta.State.EXPIRED) {
336+
if (meta.expectedSizeBytes > 0 && meta.state != UploadSessionMeta.State.ABORTED) {
337337
storageTracker.releaseReservation(meta.accountId, meta.expectedSizeBytes)
338338
}
339339
log(TAG) { "terminateSession(${meta.sessionId}): $reason" }

0 commit comments

Comments
 (0)