Skip to content

Commit ae4d8ba

Browse files
restore null check (#8172)
## Rationale Move null check (previously removed from @NotNull method) to caller. ## Related Pull Requests - <!-- list of links to related pull requests (replace this comment) --> ## Changes - <!-- list of descriptions of changes that are worth noting (replace this comment) --> <!-- list of standard tasks (remove this comment to enable) ## Tasks - [ ] Claude Code Review - [ ] Manual Testing - [ ] Test Automation - [ ] Verify Fix -->
1 parent 5bc1aa5 commit ae4d8ba

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

‎api/src/org/labkey/api/webdav/FileSystemResource.java‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.labkey.api.audit.AuditTypeEvent;
3030
import org.labkey.api.audit.provider.FileSystemAuditProvider;
3131
import org.labkey.api.collections.CaseInsensitiveHashSet;
32+
import org.labkey.api.data.Container;
3233
import org.labkey.api.data.SimpleFilter;
3334
import org.labkey.api.data.TableInfo;
3435
import org.labkey.api.exp.api.ExpData;
@@ -589,30 +590,35 @@ public boolean delete(User user)
589590
if (file == null || (null != user && !canDelete(user, true, null)))
590591
return false;
591592

592-
try {
593-
FileContentService svc = FileContentService.get();
594-
AttachmentDirectory dir;
595-
dir = svc.getMappedAttachmentDirectory(getContainer(), false);
596-
String fileDirPath = file.getParent();
597-
598-
// 23746: If file exists in parent with the same name it was deleted instead
599-
if (dir != null && fileDirPath != null && dir.getFileSystemDirectoryPath().toAbsolutePath().toString().equals(fileDirPath))
593+
// Resources that aren't in a container (e.g., module resources) can't have legacy file attachments
594+
Container c = getContainer();
595+
if (c != null)
596+
{
597+
try
600598
{
601-
// legacy support for files added through the narrow files web part but deleted through
602-
// the newer file browser (issue: 11396). This is the difference between files stored through
603-
// webdav or via the attachments service.
604-
//
605-
Attachment attach = AttachmentService.get().getAttachment(dir, file.getName());
606-
if (attach != null)
599+
FileContentService svc = FileContentService.get();
600+
AttachmentDirectory dir = svc.getMappedAttachmentDirectory(c, false);
601+
String fileDirPath = file.getParent();
602+
603+
// 23746: If file exists in parent with the same name it was deleted instead
604+
if (dir != null && fileDirPath != null && dir.getFileSystemDirectoryPath().toAbsolutePath().toString().equals(fileDirPath))
607605
{
608-
AttachmentService.get().deleteAttachment(dir, file.getName(), null);
609-
return (AttachmentService.get().getAttachment(dir, file.getName()) == null);
606+
// legacy support for files added through the narrow files web part but deleted through
607+
// the newer file browser (issue: 11396). This is the difference between files stored through
608+
// webdav or via the attachments service.
609+
//
610+
Attachment attach = AttachmentService.get().getAttachment(dir, file.getName());
611+
if (attach != null)
612+
{
613+
AttachmentService.get().deleteAttachment(dir, file.getName(), null);
614+
return (AttachmentService.get().getAttachment(dir, file.getName()) == null);
615+
}
610616
}
611617
}
612-
}
613-
catch (Exception e)
614-
{
615-
_log.error(e);
618+
catch (Exception e)
619+
{
620+
_log.error(e);
621+
}
616622
}
617623
boolean deleted = file.delete();
618624
if (!deleted)

0 commit comments

Comments
 (0)