Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderIconAndFilename() expects actual path #6052

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions api/src/org/labkey/api/study/assay/FileLinkDisplayColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.io.InputStream;
import java.io.Writer;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -252,10 +253,20 @@ protected String getFileName(RenderContext ctx, Object value, boolean isDisplay)
String result = value == null ? null : StringUtils.trimToNull(value.toString());
if (result != null)
{
File f;
File f = null;
if (result.startsWith("file:"))
f = new File(URI.create(result));
else
{
try
{
f = new File(new URI(result));
}
catch (URISyntaxException x)
{
// try to recover
result = result.substring("file:".length());
}
}
if (null == f)
f = FileUtil.getAbsoluteCaseSensitiveFile(new File(result));
NetworkDrive.ensureDrive(f.getPath());
List<FileContentService.ContentType> fileRootTypes = List.of(FileContentService.ContentType.files, FileContentService.ContentType.pipeline, FileContentService.ContentType.assayfiles);
Expand All @@ -270,7 +281,7 @@ protected String getFileName(RenderContext ctx, Object value, boolean isDisplay)
result = f.getName();
}

if (isDisplay && !f.exists())
if (isDisplay && !f.exists() && !result.endsWith("(unavailable)"))
result += " (unavailable)";
}
return result;
Expand Down Expand Up @@ -339,7 +350,7 @@ else if (f.isDirectory())
else
{
// It's not on the file system anymore, so don't offer a link and tell the user it's unavailable
super.renderIconAndFilename(ctx, out, filename + " (unavailable)", Attachment.getFileIcon(filename), null, false, false);
super.renderIconAndFilename(ctx, out, filename, Attachment.getFileIcon(filename), null, false, false);
}
}
else
Expand Down