{"record":{"id":"25ef23a49d6d33ef","repo":"libnyanpasu/clash-nyanpasu","slug":"backup-symlink-specification-is-not-a-regular-file","errorCode":null,"errorMessage":"backup symlink specification is not a regular file","messagePattern":"backup symlink specification is not a regular file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/service/profile_file.rs","lineNumber":864,"sourceCode":"            Ok(metadata) => Some(metadata),\n            Err(error) if error.kind() == std::io::ErrorKind::NotFound => None,\n            Err(error) => {\n                return Err(error)\n                    .with_context(|| format!(\"inspect backup link {}\", link_path.display()));\n            }\n        };\n        if file_metadata.is_some() && link_metadata.is_some() {\n            bail!(\"materialization has multiple backups\");\n        }\n        if let Some(metadata) = file_metadata {\n            if is_symlink_or_reparse(&metadata) || !metadata.is_file() {\n                bail!(\"backup file is not a regular file\");\n            }\n            return Ok(Some(StoredResource::File { path: file_path }));\n        }\n        if let Some(metadata) = link_metadata {\n            if is_symlink_or_reparse(&metadata) || !metadata.is_file() {\n                bail!(\"backup symlink specification is not a regular file\");\n            }\n            let target = std::fs::read_to_string(&link_path)?;\n            return Ok(Some(StoredResource::Symlink {\n                target: ExternalProfilePath::new(target)?,\n            }));\n        }\n        Ok(None)\n    }\n\n    fn create_ready_link(\n        root: &Path,\n        operation_id: &str,\n        target: &ExternalProfilePath,\n    ) -> anyhow::Result<PathBuf> {\n        let ready = Self::ready_link_path(root, operation_id);\n        match std::fs::symlink_metadata(&ready) {\n            Ok(metadata) if metadata.file_type().is_symlink() => {\n                if std::fs::read_link(&ready)? != target.as_path() {","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/service/profile_file.rs#L846-L882","documentation":"read_backup_resource reads the backed-up symlink specification (a plain file containing the original symlink target string). The spec file exists but is not a regular file (symlink/reparse point, directory, etc.), so the code refuses to read it for rollback to avoid following untrusted or corrupted nodes.","triggerScenarios":"backup_link_path(root, operation_id) exists but symlink_metadata reports a symlink/reparse point or a non-regular file — the spec was replaced by a link or the backup filesystem reports it as a special node.","commonSituations":"Backup dir tampering or wrong-file placement; storage on filesystems with reparse points (Windows junctions, OneDrive placeholder files, network mounts); restore tools that recreated backup files as links.","solutions":["Delete the non-regular node at the backup link path and re-run the operation so the spec is rewritten as a regular file.","Move the backup root to a local plain filesystem away from junctions/placeholder-file services.","If the original managed symlink still exists and is valid, redo the materialization to recapture a clean backup."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let md = std::fs::symlink_metadata(backup_link_path)?;\nif md.is_symlink() || !md.is_file() {\n    std::fs::remove_file(backup_link_path)?;\n}","typeGuard":"fn is_regular_file_node(p: &Path) -> bool {\n    std::fs::symlink_metadata(p).map(|m| !m.is_symlink() && m.is_file()).unwrap_or(false)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"backup symlink specification is not a regular file\") => {\n        clear_backup_dir(root, op_id)?;\n        retry()\n    }\n    other => other,\n}","preventionTips":["Avoid OneDrive/placeholder-file locations for the backup root.","Don't restore backup directories with tools that recreate files as symlinks.","Pre-check backup nodes are regular files before invoking rollback/read."],"tags":["filesystem","symlink","backup","rust"],"backgroundTag":"unsupported-operation","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}