From 029b83042da6ef896224260f93fbe26ebe6e1721 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 6 Oct 2018 12:58:54 +0200 Subject: [PATCH] Fix detecting of external links Checking whether we have a file (on the FS) here is not enough for either case (external link/internal link). Thus, we should check whether a store entry with that ID exists. If it does, we link internally, else externally by trying to parse the string as URL. Signed-off-by: Matthias Beyer --- bin/core/imag-link/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/core/imag-link/src/main.rs b/bin/core/imag-link/src/main.rs index 46ce39e9..8f839f90 100644 --- a/bin/core/imag-link/src/main.rs +++ b/bin/core/imag-link/src/main.rs @@ -147,7 +147,7 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I) for entry in to { debug!("Handling 'to' entry: {:?}", entry); - if PathBuf::from(entry).exists() { + if !rt.store().get(PathBuf::from(entry)).map_err_trace_exit_unwrap(1).is_some() { debug!("Linking externally: {:?} -> {:?}", from, entry); let url = Url::parse(entry).unwrap_or_else(|e| { error!("Error parsing URL: {:?}", e);