tonhowtf/omniget · error

a gravacao atual nao e um replay

Error message

a gravacao atual nao e um replay

What it means

save_replay requires the active session to have a ring buffer directory (ring_dir), which only exists when recording was started in replay mode. When a session exists but was started without replay, this error ('a gravacao atual nao e um replay') is thrown. The current recording is not a replay, so there is no segment ring to stitch.

Solutions

  1. Restart the recording with replay mode enabled so ring_dir is populated.
  2. Verify the start-recording options include replay_seconds > 0.
  3. Gate the replay UI action on session.replay capability instead of generic recording state.

Example fix

// before
save_replay().await?;
// after
let opts = RecordingOptions { replay_seconds: 60, ..opts };
start_recording(opts).await?;
save_replay().await?;
Defensive patterns

Strategy: validation

Validate before calling

// Rust
fn session_is_replay(s: &Option<Session>) -> bool {
    s.as_ref().and_then(|s| s.ring_dir.as_ref()).is_some()
}

Type guard

fn is_replay_session(s: &Session) -> bool { s.ring_dir.is_some() }

Try / catch

match save_replay().await {
    Err(e) if e.to_string().contains("nao e um replay") => {
        // reiniciar gravacao em modo replay ou avisar o usuario
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling save_replay() while a recording session is active, but that session was started with replay disabled (ring_dir is None).

Common situations: User starts a normal recording, then the app exposes a 'save last 60s' action that only works for replay-mode sessions; config flag for replay not passed through when starting recording; version where replay defaulted on now defaults off.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/26f17c16b8fe90ab. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/screen_record.rs:443

        *LAST_SAVED.lock().unwrap_or_else(|e| e.into_inner()) =
            Some(out.to_string_lossy().to_string());
    }
    if let Some(r) = &sess.ring_dir {
        let _ = std::fs::remove_dir_all(r);
    }
    Ok(state())
}

/// Replay: junta os últimos segmentos num arquivo na pasta de saída, sem
/// interromper a gravação do anel.
pub async fn save_replay() -> anyhow::Result<String> {
    let (ring, opts) = {
        let s = SESSION.lock().unwrap_or_else(|e| e.into_inner());
        let Some(sess) = s.as_ref() else {
            return Err(anyhow!("o replay nao esta ligado"));
        };
        let Some(r) = sess.ring_dir.clone() else {
            return Err(anyhow!("a gravacao atual nao e um replay"));
        };
        (r, sess.opts.clone())
    };
    let ffmpeg = crate::core::dependencies::ensure_ffmpeg().await?;
    let mut segs: Vec<(std::time::SystemTime, PathBuf)> = std::fs::read_dir(&ring)?
        .flatten()
        .filter_map(|e| {
            let p = e.path();
            let m = e.metadata().ok()?;
            if p.extension().map(|x| x == "mp4").unwrap_or(false) && m.len() > 0 {
                Some((m.modified().ok()?, p))
            } else {
                None
            }
        })
        .collect();
    segs.sort();
    // O último segmento ainda está sendo escrito; pega os anteriores.

View on GitHub (pinned to 8600b91f42)