{"record":{"id":"acf76bc421633faf","repo":"rustdesk/rustdesk","slug":"failed-to-create-parent-directory-when-stagin","errorCode":null,"errorMessage":"Failed to create parent directory {:?} when staging custom client files: {}","messagePattern":"Failed to create parent directory (.+?) when staging custom client files: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/platform/windows.rs","lineNumber":3849,"sourceCode":"                    \"Failed to read metadata for custom.txt at {:?}: {}\",\n                    src_path,\n                    e\n                );\n            }\n        };\n\n        if metadata.is_symlink() {\n            allow_err!(remove_custom_client_staging_dir(&custom_client_staging_dir));\n            bail!(\n                \"custom.txt at {:?} is a symlink, refusing to stage for security reasons.\",\n                src_path\n            );\n        }\n\n        if metadata.is_file() {\n            if !custom_client_staging_dir.exists() {\n                if let Err(e) = std::fs::create_dir_all(custom_client_staging_dir) {\n                    bail!(\"Failed to create parent directory {:?} when staging custom client files: {}\", custom_client_staging_dir, e);\n                }\n            }\n            let dst_path = custom_client_staging_dir.join(\"custom.txt\");\n            if let Err(e) = std::fs::copy(&src_path, &dst_path) {\n                allow_err!(remove_custom_client_staging_dir(&custom_client_staging_dir));\n                bail!(\n                    \"Failed to copy custom txt from {:?} to {:?}: {}\",\n                    src_path,\n                    dst_path,\n                    e\n                );\n            }\n        } else {\n            log::warn!(\n                \"custom.txt at {:?} is not a regular file, skipping.\",\n                src_path\n            );\n        }","sourceCodeStart":3831,"sourceCodeEnd":3867,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540/src/platform/windows.rs#L3831-L3867","documentation":"Before copying `custom.txt` into the staging directory, the code ensures the staging directory exists with `std::fs::create_dir_all`. Failure to create it aborts the update with this error, which includes the target directory and the underlying io::Error.","triggerScenarios":"`custom.txt` is a regular file and the staging directory does not exist, but `create_dir_all` fails — path is invalid/too long, access denied under the staging root, or a file exists where a directory component is expected.","commonSituations":"Staging root on a read-only or admin-only location; a stray file occupying the directory path; MAX_PATH issues; antivirus blocking directory creation.","solutions":["Check for a file (not directory) sitting at the staging path and remove it","Run the update elevated / fix ACLs on the staging root directory","Shorten the path or move the staging root if MAX_PATH or invalid characters are involved"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if !staging_dir.exists() {\n    // ensure parent chain is creatable and no file blocks the path\n    if let Some(parent) = staging_dir.parent() {\n        assert!(std::fs::metadata(parent).map(|m| m.is_dir()).unwrap_or(false));\n    }\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = std::fs::create_dir_all(&staging_dir) {\n    if e.kind() == std::io::ErrorKind::PermissionDenied {\n        // request elevation or choose another staging root\n    }\n}","preventionTips":["Check no regular file occupies the staging directory path","Run updates from an account with write access to the staging root","Watch for MAX_PATH problems on deeply nested staging roots"],"tags":["windows","filesystem","mkdir"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540","analyzedAt":"2026-09-10T19:53:44.083Z","contentChangedAt":"2026-09-10T19:53:44.083Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}