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

[bot] Fast-forward for 24.11.11 #6372

Merged
merged 5 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions api/src/org/labkey/api/exp/XarSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public XarSource(PipelineJob job)

public abstract Path getRootPath();

public Path getJobRootPath() { return getRootPath(); }

/**
* Should be true if this was uploaded XML that was not part of a full XAR
*/
Expand Down
8 changes: 6 additions & 2 deletions api/src/org/labkey/api/util/NetworkDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,12 @@ public static boolean exists(java.nio.file.Path p)
return false;
if (Files.exists(p))
return true;
ensureDrive(p.toString());
return Files.exists(p);
if (FileUtil.FILE_SCHEME.equals(p.toUri().getScheme()))
{
ensureDrive(p.toString());
return Files.exists(p);
}
return false;
}

public static void ensureDrive(FileLike f)
Expand Down
2 changes: 1 addition & 1 deletion core/src/org/labkey/core/security/SecurityController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ public void setMailPrefix(String mailPrefix)
public @NotNull User getUser(boolean throwIfNull)
{
if (throwIfNull && null == _user)
throw new IllegalStateException("User not found");
throw new NotFoundException("User not found");

return _user;
}
Expand Down
7 changes: 6 additions & 1 deletion experiment/src/org/labkey/experiment/ExpDataIterators.java
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,12 @@ private TypeData createSampleHeaderRow(ExpSampleTypeImpl sampleType, Container c
ColumnInfo colInfo = getColumnInfo(i);
String name = colInfo.getName();
String lcName = name.toLowerCase();
if (validFields.contains(name))
if (_typeColIndex != null && _typeColIndex == i) // Issue 52355: assure we have some data in the row by including the type
{
fieldIndexes.add(i);
header.add(_typeColName);
}
else if (validFields.contains(name))
{
fieldIndexes.add(i);
header.add(_tsvWriter.quoteValue(name));
Expand Down
2 changes: 1 addition & 1 deletion experiment/src/org/labkey/experiment/XarReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ private void loadExperimentRun(ExperimentRunType a, List<ExpMaterial> startingMa
vals.setProtocolLSID(protocol.getLSID());
vals.setComments(trimString(a.getComments()));

vals.setFilePathRoot(FileUtil.getAbsolutePath(_xarSource.getRootPath())); // FileUtil.getAbsolutePath(runContext.getContainer(), _job.getPipeRoot().getRootNioPath()));
vals.setFilePathRoot(FileUtil.getAbsolutePath(_xarSource.getJobRootPath()));
vals.setContainer(getContainer());
String workflowTaskLSID = a.getWorkflowTaskLSID();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ public Path getRootPath()
return FileUtil.stringToPath(_sourceContainer, _root);
}

@Override
public Path getJobRootPath()
{
var pipelineJob = getXarContext().getJob();
return pipelineJob != null
? pipelineJob.getPipeRoot().getRootFileLike().toNioPathForRead()
: super.getJobRootPath();
}

@Override
public boolean shouldIgnoreDataFiles()
{
Expand Down
45 changes: 23 additions & 22 deletions filecontent/src/org/labkey/filecontent/FileContentServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.GUID;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.NetworkDrive;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.Path;
import org.labkey.api.util.TestContext;
Expand Down Expand Up @@ -339,7 +340,7 @@ public java.nio.file.Path getDefaultRootPath(Container c, boolean createDir)

try
{
if (createDir && !Files.exists(fileRootPath))
if (createDir && !NetworkDrive.exists(fileRootPath))
FileUtil.createDirectories(fileRootPath);
}
catch (IOException e)
Expand Down Expand Up @@ -602,7 +603,7 @@ public void setIsUseDefaultRoot(Container c, boolean useDefaultRoot)

try
{
if (root == null || !root.exists())
if (!NetworkDrive.exists(root))
{
File configuredRoot = root;
root = getDefaultRoot();
Expand All @@ -621,7 +622,7 @@ public void setIsUseDefaultRoot(Container c, boolean useDefaultRoot)
_problematicFileRootMessage = null;
}

if (!root.exists())
if (!NetworkDrive.exists(root))
{
if (FileUtil.mkdirs(root))
{
Expand Down Expand Up @@ -658,7 +659,7 @@ public String getProblematicFileRootMessage()
root = root.getParentFile();
}
File defaultRoot = new File(root, "files");
if (!defaultRoot.exists())
if (!NetworkDrive.exists(defaultRoot))
FileUtil.mkdirs(defaultRoot);

return defaultRoot;
Expand All @@ -670,7 +671,7 @@ public void setSiteDefaultRoot(File root, User user)
if (root == null)
throw new IllegalArgumentException("Invalid site root: specified root is null");

if (!root.exists())
if (!NetworkDrive.exists(root))
throw new IllegalArgumentException("Invalid site root: " + root.getAbsolutePath() + " does not exist");

File prevRoot = getSiteDefaultRoot();
Expand Down Expand Up @@ -764,7 +765,7 @@ public java.nio.file.Path getMappedDirectory(Container c, boolean create) throws
return null;
}

if (!Files.exists(root))
if (!NetworkDrive.exists(root))
{
if (create)
throw new MissingRootDirectoryException(c.isRoot() ? c : c.getProject(), root);
Expand Down Expand Up @@ -862,7 +863,7 @@ public void containerMoved(Container c, Container oldParent, User user)
if (!FileUtil.hasCloudScheme(srcParent))
{
File src = new File(srcParent.toFile(), c.getName());
if (src.exists())
if (NetworkDrive.exists(src))
{
if (!FileUtil.hasCloudScheme(dest))
{
Expand All @@ -873,7 +874,7 @@ public void containerMoved(Container c, Container oldParent, User user)
{
// local -> cloud; source starts under @files
File filesSrc = FileUtil.appendName(src, FILES_LINK);
if (filesSrc.exists())
if (NetworkDrive.exists(filesSrc))
moveFileRoot(filesSrc.toPath(), dest, user, c);
FileUtil.deleteDir(src); // moveFileRoot will delete @files, but we need to delete its parent
}
Expand Down Expand Up @@ -935,10 +936,10 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent)
File parentDir = locationFile.getParentFile();
File oldLocation = new File(parentDir, oldValue);
File newLocation = new File(parentDir, newValue);
if (newLocation.exists())
if (NetworkDrive.exists(newLocation))
moveToDeleted(newLocation);

if (oldLocation.exists())
if (NetworkDrive.exists(oldLocation))
{
oldLocation.renameTo(newLocation);
fireFileMoveEvent(oldLocation, newLocation, evt.user, evt.container);
Expand Down Expand Up @@ -972,18 +973,18 @@ public void propertyChange(PropertyChangeEvent propertyChangeEvent)
*/
private static boolean moveToDeleted(File fileToMove) throws IOException
{
if (!fileToMove.exists())
if (!NetworkDrive.exists(fileToMove))
return false;

File parent = fileToMove.getParentFile();

File deletedDir = new File(parent, ".deleted");
if (!deletedDir.exists())
if (!NetworkDrive.exists(deletedDir))
if (!FileUtil.mkdir(deletedDir))
return false;

File newLocation = new File(deletedDir, fileToMove.getName());
if (newLocation.exists())
if (NetworkDrive.exists(newLocation))
FileUtil.deleteDir(newLocation);

return fileToMove.renameTo(newLocation);
Expand Down Expand Up @@ -1093,7 +1094,7 @@ public QueryUpdateService getFilePropsUpdateService(TableInfo tinfo, Container c
public boolean isValidProjectRoot(String root)
{
File f = new File(root);
return f.exists() && f.isDirectory();
return NetworkDrive.exists(f) && f.isDirectory();
}

@Override
Expand Down Expand Up @@ -1131,7 +1132,7 @@ public void moveFileRoot(File prev, File dest, @Nullable User user, @Nullable Co
// If it exists, try deleting the target directory, which will only succeed if it's empty, but would
// enable using renameTo() method. Don't delete if it's a symbolic link, since it wouldn't be recreated
// in the same way.
if (dest.exists() && !Files.isSymbolicLink(dest.toPath()))
if (NetworkDrive.exists(dest) && !Files.isSymbolicLink(dest.toPath()))
doRename = dest.delete();

if (doRename && !prev.renameTo(dest))
Expand Down Expand Up @@ -1292,7 +1293,7 @@ public Set<Map<String, Object>> getNodes(boolean isShowOverridesOnly, @Nullable

try {
java.nio.file.Path assayFilesRoot = getFileRootPath(c, ContentType.assayfiles);
if (assayFilesRoot != null && Files.exists(assayFilesRoot))
if (NetworkDrive.exists(assayFilesRoot))
{
Map<String, Object> node = createFileSetNode(c, ASSAY_FILES, assayFilesRoot);
node.put("default", false);
Expand Down Expand Up @@ -1646,7 +1647,7 @@ public File getMoveTargetFile(String absoluteFilePath, @NotNull Container source
return null;

File file = new File(absoluteFilePath);
if (!file.exists())
if (!NetworkDrive.exists(file))
{
_log.warn("File '" + absoluteFilePath + "' not found and cannot be moved");
return null;
Expand Down Expand Up @@ -1779,7 +1780,7 @@ private File getTestRoot()
File siteRoot = svc.getSiteDefaultRoot();
File testRoot = new File(siteRoot, FILE_ROOT_SUFFIX);
testRoot.mkdirs();
Assert.assertTrue("Unable to create test file root", testRoot.exists());
Assert.assertTrue("Unable to create test file root", NetworkDrive.exists(testRoot));

return testRoot;
}
Expand Down Expand Up @@ -1843,7 +1844,7 @@ public void testFolderMove() throws Exception
_log,
false);

Assert.assertTrue("File not found: " + childFile.getPath(), childFile.exists());
Assert.assertTrue("File not found: " + childFile.getPath(), NetworkDrive.exists(childFile));
ContainerManager.move(subsubfolder, subfolder2, TestContext.get().getUser());
Container movedSubfolder = ContainerManager.getChild(subfolder2, subsubfolder.getName());

Expand All @@ -1852,7 +1853,7 @@ public void testFolderMove() throws Exception
assertPathsEqual("SubSubfolder has incorrect root", _expectedPaths.get(movedSubfolder), svc.getFileRoot(movedSubfolder));

File expectedFile = new File(svc.getFileRoot(movedSubfolder, ContentType.files), TXT_FILE);
Assert.assertTrue("File was not moved, expected: " + expectedFile.getPath(), expectedFile.exists());
Assert.assertTrue("File was not moved, expected: " + expectedFile.getPath(), NetworkDrive.exists(expectedFile));

ExpData movedData = ExperimentService.get().getExpData(data.getRowId());
Assert.assertNotNull(movedData);
Expand Down Expand Up @@ -1938,7 +1939,7 @@ public void cleanup()
deleteContainerAndFiles(svc, ContainerManager.getForPath(PROJECT2));

File testRoot = getTestRoot();
if (testRoot.exists())
if (NetworkDrive.exists(testRoot))
{
FileUtil.deleteDir(testRoot);
}
Expand All @@ -1951,7 +1952,7 @@ private void deleteContainerAndFiles(FileContentService svc, @Nullable Container
ContainerManager.deleteAll(c, TestContext.get().getUser());

File file1 = svc.getFileRoot(c);
if (file1 != null && file1.exists())
if (NetworkDrive.exists(file1))
{
FileUtil.deleteDir(file1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public boolean cancelJob(User user, Container c, PipelineStatusFile statusFile)
if (cancelRemoteExecutionEngineJob(statusFile, job)) return true;
}

PipelineJobService.get().cancelForJob(statusFile.getJobId());

return false;
}
Expand Down