Skip to content

Commit c569b99

Browse files
committed
publish: allow symlinked media root
1 parent 7800ebb commit c569b99

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/jobs/publish_job.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,16 @@ fn copy_screenshot_file(
300300
}
301301

302302
fn open_media_dir(media_dir: &Path) -> JobResult<File> {
303-
open_dir_path_no_follow(media_dir).map_err(|err| {
303+
let media_dir = media_dir.canonicalize().map_err(|err| {
304304
unsafe_screenshot_destination(
305305
media_dir,
306+
format!("is not a real directory or could not be resolved: {err}"),
307+
)
308+
})?;
309+
310+
open_dir_path_no_follow(&media_dir).map_err(|err| {
311+
unsafe_screenshot_destination(
312+
&media_dir,
306313
format!("is not a real directory or could not be opened: {err}"),
307314
)
308315
})
@@ -811,4 +818,22 @@ mod tests {
811818
);
812819
assert!(!repo.path().join("screenshots/flat-manager.json").exists());
813820
}
821+
822+
#[test]
823+
fn allows_configured_media_directory_symlink() {
824+
let repo = tempfile::tempdir().unwrap();
825+
let media_target = tempfile::tempdir().unwrap();
826+
let staged = tempfile::tempdir().unwrap();
827+
let media = repo.path().join("media");
828+
let relative_path = Path::new("screenshots/flat-manager.json");
829+
symlink(media_target.path(), &media).unwrap();
830+
write_file(&staged.path().join(relative_path), "new");
831+
832+
install_staged_screenshot_tree(staged.path(), &media).unwrap();
833+
834+
assert_eq!(
835+
fs::read_to_string(media_target.path().join(relative_path)).unwrap(),
836+
"new"
837+
);
838+
}
814839
}

0 commit comments

Comments
 (0)