{"record":{"id":"48192d54ee363047","repo":"libnyanpasu/clash-nyanpasu","slug":"backup-file-is-not-a-regular-file","errorCode":null,"errorMessage":"backup file is not a regular file","messagePattern":"backup file is not a regular file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/service/profile_file.rs","lineNumber":858,"sourceCode":"            Err(error) => {\n                return Err(error)\n                    .with_context(|| format!(\"inspect backup file {}\", file_path.display()));\n            }\n        };\n        let link_metadata = match std::fs::symlink_metadata(&link_path) {\n            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,","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/service/profile_file.rs#L840-L876","documentation":"read_backup_resource validates that the backed-up file blob is a regular file before using it for rollback. The backup file path exists but is a symlink/reparse point or otherwise not a regular file, so it cannot be trusted as a restorable backup and the operation aborts.","triggerScenarios":"backup_file_path(root, operation_id) exists but symlink_metadata reports a symlink/reparse point or a non-regular file — the backup blob was replaced by a link, or the backup root lives on a filesystem that reports special file types (network mount, Windows reparse).","commonSituations":"Tampering or accidental modification of the backup directory; backup root on OneDrive/NFS/overlay storage; sync tools rewriting stored blobs as links; manual copy operations that dereferenced/converted files.","solutions":["Clear the backup area for this operation_id and re-run the materialization so a fresh regular-file backup is captured.","Relocate the backup root to a plain local filesystem.","Check for tools (backup/sync/AV) converting files into links inside the backup directory.","If the original target still exists as a valid file/symlink, you can re-run capture_backup by redoing the materialization."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let md = std::fs::symlink_metadata(backup_file_path)?;\nif md.is_symlink() || !md.is_file() {\n    std::fs::remove_file(backup_file_path)?; // drop unusable backup before retry\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 file is not a regular file\") => {\n        clear_backup_dir(root, op_id)?;\n        retry()\n    }\n    other => other,\n}","preventionTips":["Store backups on plain local filesystems.","Exclude the backup root from sync/AV tools that rewrite files as links.","Don't manually replace files in the backup directory."],"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"}