Skip to content

Commit fc84849

Browse files
committed
Auto merge of #14402 - Veykril:project-json-sym-link, r=Veykril
internal: Reject symlinks in project-json cc #14168
2 parents 68aa133 + c01ba4a commit fc84849

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/project-model/src/workspace.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use std::{collections::VecDeque, fmt, fs, process::Command, sync::Arc};
66

7-
use anyhow::{format_err, Context, Result};
7+
use anyhow::{bail, format_err, Context, Result};
88
use base_db::{
99
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env,
1010
FileId, LangCrateOrigin, ProcMacroLoadResult, TargetLayoutLoadResult,
@@ -154,6 +154,12 @@ impl ProjectWorkspace {
154154
) -> Result<ProjectWorkspace> {
155155
let res = match manifest {
156156
ProjectManifest::ProjectJson(project_json) => {
157+
let metadata = fs::symlink_metadata(&project_json).with_context(|| {
158+
format!("Failed to read json file {}", project_json.display())
159+
})?;
160+
if metadata.is_symlink() {
161+
bail!("The project-json may not currently point to a symlink");
162+
}
157163
let file = fs::read_to_string(&project_json).with_context(|| {
158164
format!("Failed to read json file {}", project_json.display())
159165
})?;

0 commit comments

Comments
 (0)