{"record":{"id":"e628e533ef79ef00","repo":"pot-app/pot-desktop","slug":"create-cache-dir-failed","errorCode":null,"errorMessage":"Create Cache Dir Failed","messagePattern":"Create Cache Dir Failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/screenshot.rs","lineNumber":20,"sourceCode":"\n#[tauri::command]\npub fn screenshot(x: i32, y: i32) {\n    use crate::APP;\n    use dirs::cache_dir;\n    use screenshots::{Compression, Screen};\n    use std::fs;\n    info!(\"Screenshot screen with position: x={}, y={}\", x, y);\n    let screens = Screen::all().unwrap();\n    for screen in screens {\n        let info = screen.display_info;\n        info!(\"Screen: {:?}\", info);\n        if info.x == x && info.y == y {\n            let handle = APP.get().unwrap();\n            let mut app_cache_dir_path = cache_dir().expect(\"Get Cache Dir Failed\");\n            app_cache_dir_path.push(&handle.config().tauri.bundle.identifier);\n            if !app_cache_dir_path.exists() {\n                // 创建目录\n                fs::create_dir_all(&app_cache_dir_path).expect(\"Create Cache Dir Failed\");\n            }\n            app_cache_dir_path.push(\"pot_screenshot.png\");\n\n            let image = screen.capture().unwrap();\n            let buffer = image.to_png(Compression::Fast).unwrap();\n            fs::write(app_cache_dir_path, buffer).unwrap();\n            break;\n        }\n    }\n}\n","sourceCodeStart":2,"sourceCodeEnd":31,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src-tauri/src/screenshot.rs#L2-L31","documentation":"In screenshot, after building the app cache path (<cache_dir>/<bundle.identifier>), fs::create_dir_all failed (returned Err) and .expect('Create Cache Dir Failed') panicked. This means the directory could not be created — typically a permissions problem, a read-only filesystem, or a non-directory file already occupying that path — so the screenshot file cannot be written.","triggerScenarios":"Thrown at src-tauri/src/screenshot.rs:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check filesystem permissions on the cache directory and that it is writable by the app user","Ensure no regular file exists at the target path that blocks directory creation","Handle the io::Error (match on kind) and surface it to the frontend instead of panicking","Fall back to a temp directory if the cache location is unusable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"594d32ede96acd106b0256deaa8bb440ffcdff40","analyzedAt":"2026-09-02T18:12:21.811Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}