Skip to content

Commit

Permalink
renderIconAndFilename() expects actual path
Browse files Browse the repository at this point in the history
belt and suspenders fix for !f.exists()
  • Loading branch information
labkey-matthewb committed Nov 13, 2024
1 parent 5ab00fa commit 83acac3
Showing 1 changed file with 16 additions and 5 deletions.
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

0 comments on commit 83acac3

Please sign in to comment.