{"record":{"id":"6bc09099f6ff2b8d","repo":"tonhowtf/omniget","slug":"ainda-nao-ha-nada-no-buffer","errorCode":null,"errorMessage":"ainda nao ha nada no buffer","messagePattern":"ainda nao ha nada no buffer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/omniget-core/src/core/tools/screen_record.rs","lineNumber":466,"sourceCode":"    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.\n    if segs.len() > 1 {\n        segs.pop();\n    }\n    if segs.is_empty() {\n        return Err(anyhow!(\"ainda nao ha nada no buffer\"));\n    }\n    let want = (opts.replay_seconds.max(10) / 5) as usize;\n    let chosen: Vec<PathBuf> = segs\n        .iter()\n        .rev()\n        .take(want)\n        .map(|(_, p)| p.clone())\n        .collect::<Vec<_>>()\n        .into_iter()\n        .rev()\n        .collect();\n    let list = ring.join(\"concat.txt\");\n    std::fs::write(\n        &list,\n        chosen\n            .iter()\n            .map(|p| format!(\"file '{}'\", p.to_string_lossy().replace('\\'', \"'\\\\''\")))\n            .collect::<Vec<_>>()","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/screen_record.rs#L448-L484","documentation":"save_replay collects existing segment files from the ring directory, dropping the last segment that is still being written. If, after that, no segments remain (segs.is_empty()), there is nothing to concatenate, so 'ainda nao ha nada no buffer' (nothing in the buffer yet) is thrown. Replay needs at least one completed 5-second segment.","triggerScenarios":"Calling save_replay() less than ~5-10 seconds after starting a replay recording, so the only segment on disk is still being written (or none exist yet).","commonSituations":"User starts recording and immediately clicks 'save replay'; very short replay_seconds value; slow disk writes delaying the first segment flush.","solutions":["Wait until at least one full segment (~5s) plus rollover has completed before calling save_replay.","Retry after a short delay if the action is user-triggered too early.","Increase replay_seconds so the requested window covers more segments."],"exampleFix":"// before\nlet out = save_replay().await?;\n// after\nif seconds_since_recording_start() < 10 {\n    tokio::time::sleep(std::time::Duration::from_secs(5)).await;\n}\nlet out = save_replay().await?;","handlingStrategy":"retry","validationCode":"// Rust\nasync fn replay_ready(min_age: Duration) -> bool {\n    elapsed_since_recording_start() >= min_age\n}","typeGuard":"null","tryCatchPattern":"let mut attempt = 0;\nlet out = loop {\n    match save_replay().await {\n        Err(e) if e.to_string().contains(\"ainda nao ha nada\") && attempt < 3 => {\n            attempt += 1;\n            tokio::time::sleep(Duration::from_secs(3)).await;\n        }\n        r => break r,\n    }\n}?;","preventionTips":["Enforce a minimum elapsed time (>= replay segment length) before allowing replay saves","Debounce the replay-save UI action","Set replay_seconds well above the segment length"],"tags":["replay","empty-buffer","rust","timing"],"backgroundTag":"empty-result-set","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"}