{"record":{"id":"26f17c16b8fe90ab","repo":"tonhowtf/omniget","slug":"a-gravacao-atual-nao-e-um-replay","errorCode":null,"errorMessage":"a gravacao atual nao e um replay","messagePattern":"a gravacao atual nao e um replay","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/screen_record.rs","lineNumber":443,"sourceCode":"        *LAST_SAVED.lock().unwrap_or_else(|e| e.into_inner()) =\n            Some(out.to_string_lossy().to_string());\n    }\n    if let Some(r) = &sess.ring_dir {\n        let _ = std::fs::remove_dir_all(r);\n    }\n    Ok(state())\n}\n\n/// Replay: junta os últimos segmentos num arquivo na pasta de saída, sem\n/// interromper a gravação do anel.\npub async fn save_replay() -> anyhow::Result<String> {\n    let (ring, opts) = {\n        let s = SESSION.lock().unwrap_or_else(|e| e.into_inner());\n        let Some(sess) = s.as_ref() else {\n            return Err(anyhow!(\"o replay nao esta ligado\"));\n        };\n        let Some(r) = sess.ring_dir.clone() else {\n            return Err(anyhow!(\"a gravacao atual nao e um replay\"));\n        };\n        (r, sess.opts.clone())\n    };\n    let ffmpeg = crate::core::dependencies::ensure_ffmpeg().await?;\n    let mut segs: Vec<(std::time::SystemTime, PathBuf)> = std::fs::read_dir(&ring)?\n        .flatten()\n        .filter_map(|e| {\n            let p = e.path();\n            let m = e.metadata().ok()?;\n            if p.extension().map(|x| x == \"mp4\").unwrap_or(false) && m.len() > 0 {\n                Some((m.modified().ok()?, p))\n            } else {\n                None\n            }\n        })\n        .collect();\n    segs.sort();\n    // O último segmento ainda está sendo escrito; pega os anteriores.","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/screen_record.rs#L425-L461","documentation":"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.","triggerScenarios":"Calling save_replay() while a recording session is active, but that session was started with replay disabled (ring_dir is None).","commonSituations":"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.","solutions":["Restart the recording with replay mode enabled so ring_dir is populated.","Verify the start-recording options include replay_seconds > 0.","Gate the replay UI action on session.replay capability instead of generic recording state."],"exampleFix":"// before\nsave_replay().await?;\n// after\nlet opts = RecordingOptions { replay_seconds: 60, ..opts };\nstart_recording(opts).await?;\nsave_replay().await?;","handlingStrategy":"validation","validationCode":"// Rust\nfn session_is_replay(s: &Option<Session>) -> bool {\n    s.as_ref().and_then(|s| s.ring_dir.as_ref()).is_some()\n}","typeGuard":"fn is_replay_session(s: &Session) -> bool { s.ring_dir.is_some() }","tryCatchPattern":"match save_replay().await {\n    Err(e) if e.to_string().contains(\"nao e um replay\") => {\n        // reiniciar gravacao em modo replay ou avisar o usuario\n    }\n    r => r?,\n}","preventionTips":["Always start recordings with replay_seconds > 0 if replay may be needed later","Expose session capabilities (replay on/off) to the UI layer","Persist the start options and validate them before enabling replay actions"],"tags":["replay","configuration","rust","screen-recording"],"backgroundTag":"invalid-state-transition","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}