Skip to content

Commit d8bb3a7

Browse files
committed
Fixed canonicalized/non-canonicalized path mismatch
1 parent 8cd6aee commit d8bb3a7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

task-maker-format/src/ioi/sanity_checks/statement.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ impl SanityCheck for StatementCompiledOrGit {
296296
return Ok(());
297297
};
298298

299+
let relative_target = relatively_resolve_symlink(path)?;
300+
299301
if booklet_dest.contains(target) {
300302
return Ok(());
301303
}
@@ -314,7 +316,7 @@ impl SanityCheck for StatementCompiledOrGit {
314316
)),
315317
)?;
316318

317-
if check_known_to_git(task, task.path_of(target))? {
319+
if check_known_to_git(task, task.path_of(&relative_target))? {
318320
return Ok(());
319321
}
320322

@@ -323,10 +325,10 @@ impl SanityCheck for StatementCompiledOrGit {
323325
eval.add_diagnostic(
324326
Diagnostic::error(format!(
325327
"The official statement at {} is not compiled by task-maker and not known to git",
326-
task.path_of(target).display()
328+
task.path_of(&relative_target).display()
327329
))
328330
.with_note("This means that it won't be available outside of your local directory")
329-
.with_help(format!("Try git add -f {}", task.path_of(target).display()))
331+
.with_help(format!("Try git add -f {}", task.path_of(&relative_target).display()))
330332
)?;
331333

332334
Ok(())
@@ -462,6 +464,14 @@ fn extract_subtasks(path: &Path, tex: &str) -> Option<Vec<ExtractedSubtask>> {
462464
.or_else(|| check_subtasks_ois(path, tex))
463465
}
464466

467+
fn relatively_resolve_symlink(path: &Path) -> Result<PathBuf, Error> {
468+
let mut path = path.to_path_buf();
469+
while path.is_symlink() {
470+
path = path.read_link()?;
471+
}
472+
Ok(path)
473+
}
474+
465475
/// Search for the statement file, returning its path or None if it doesn't exists.
466476
///
467477
/// Will return the path even in case of broken links.

0 commit comments

Comments
 (0)