Skip to content

Conversation

@labkey-jeckels
Copy link
Contributor

@labkey-jeckels labkey-jeckels commented Oct 20, 2025

Rationale

FileLike helps us do better validation of file paths. We can use it instead of File or Path in places like where the user selects files to take a pipeline action.

Changes

  • Many switches to FileLike
  • Delete a little dead code

Tasks 📍

@labkey-jeckels labkey-jeckels self-assigned this Oct 20, 2025

// Load parameter files
_parametersOverrides = getInputParameters().getInputParameters();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thought about _dirData. I imagine this often points into a larger FileSystemLike corresponding to a PipeRoot. If this analysis is supposed to read/write files in this sub-directory, is there any value in creating a new FileSystemLike rooted here?

private AnalysisScript(File script)
{
try
if (!script.exists())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is a direct path from SaveProtocolAction to here, however it's not clear that any FS specific permissions have been validated. Should there be a version of FileSystemLike.wrap (or this new?) method take a user or proof of authorization for user events? (we could also have an .unsafe() to mimic usages elsewhere e.g. SQLFragment() and HtmlString()).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the check here:

if (!submittedScripts.isEmpty() && !canUpdateTransformationScript())

It would be nice to switch to mandating that all scripts be placed in the special WebDav @scripts directory or in a module, at which point AnalysisScript could use that as the root.

I don't think that we can put a permission check at this level as the user who is executing the script by uploading assay data may not have the permissions to configure the script in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return !root.isCloudRoot() ?
new LocalDirectory(workingDir.toFile(), moduleName, baseLogFileName) :
new LocalDirectory(root.getContainer(), moduleName, root, baseLogFileName);
new LocalDirectory(workingDir.toFile(), baseLogFileName) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is a big TODO. Later...

Copy link
Contributor

@labkey-matthewb labkey-matthewb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and minor suggestions.

{
try
{
return FileSystemLike.wrapFile(getDataDirectory(), file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Ian's getVerifiedFileLike() was meant for this purpose. There should probably be a new non-static method for "adopting" a File into a FileSystemLike. E.g. FileLike ret = getDataDirectoryFileLike().wrapDescendant(File f);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea but am not sure we want to have FileLike methods that accept a File. Could be OK as an interim approach, but I'm inclined to do another pass in a followup that tries to convert a lot more of these methods (plus WorkDirectory, LocalDirectory, etc) to take FileLike instead of File or Path

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely a method to aid work in progress (then again so is wrapFile()).

{
ret = new FileSystemLocal(uri, canReadFiles, canWriteFiles, canDeleteRoot);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static FileLike getVerifiedFileLike() looks out of place here (old code), and now unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's got a few uses in OConnorLabModules where it's providing important protection against dangerous paths. Not huge to refactor but not trivial either, so I propose leaving it for this PR's purposes

List<FileLike> getChildren();

@NotNull
default List<FileLike> getChildren(Predicate<FileLike> filter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would getChildren(Predicate<Pair<String(name),Boolean(isdirectory)>> filter) be useful? That would let the FileLike impl push down the predicate (before new FileLike())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea but when I tried to implement it, it was going to be clunky to avoid checking if it's a directory when we didn't need or want to.

result.put("jmsType", PipelineService.get().getJmsType().toString());

result.put("pipelineRootCount", PipelineService.get().getAllPipelineRoots().size());
result.put("supplementalDirectories", new TableSelector(PipelineSchema.getInstance().getTableInfoPipelineRoots(), new SimpleFilter("SupplementalPath", null, CompareType.NONBLANK), null).getRowCount());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@labkey-matthewb labkey-matthewb self-requested a review October 31, 2025 19:01
@labkey-jeckels labkey-jeckels merged commit 3a59e7f into develop Nov 5, 2025
11 of 13 checks passed
@labkey-jeckels labkey-jeckels deleted the fb_pipelineFileLike branch November 5, 2025 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants