Skip to content

Commit

Permalink
Cleaning up more FilePath API restrictions (#8924)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsandell committed Feb 6, 2024
1 parent 09905a0 commit b91a57c
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ public int zip(OutputStream out, DirScanner scanner) throws IOException, Interru
* @return The number of files/directories archived.
* This is only really useful to check for a situation where nothing
*/
@Restricted(NoExternalUse.class)
public int zip(OutputStream out, DirScanner scanner, String verificationRoot, String prefix, OpenOption... openOptions) throws IOException, InterruptedException {
ArchiverFactory archiverFactory = prefix == null ? ArchiverFactory.ZIP : ArchiverFactory.createZipWithPrefix(prefix, openOptions);
return archive(archiverFactory, out, scanner, verificationRoot, openOptions);
Expand Down Expand Up @@ -515,7 +514,6 @@ public int archive(final ArchiverFactory factory, OutputStream os, final DirScan
* @return The number of files/directories archived.
* This is only really useful to check for a situation where nothing
*/
@Restricted(NoExternalUse.class)
public int archive(final ArchiverFactory factory, OutputStream os, final DirScanner scanner,
String verificationRoot, OpenOption... openOptions) throws IOException, InterruptedException {
final OutputStream out = channel != null ? new RemoteOutputStream(os) : os;
Expand Down Expand Up @@ -762,7 +760,6 @@ public String invoke(File f, VirtualChannel channel) throws IOException {
}
}

@Restricted(NoExternalUse.class)
public boolean hasSymlink(FilePath verificationRoot, OpenOption... openOptions) throws IOException, InterruptedException {
return act(new HasSymlink(verificationRoot == null ? null : verificationRoot.remote, openOptions));
}
Expand All @@ -783,7 +780,6 @@ public Boolean invoke(File f, VirtualChannel channel) throws IOException {
}
}

@Restricted(NoExternalUse.class)
public boolean containsSymlink(FilePath verificationRoot, OpenOption... openOptions) throws IOException, InterruptedException {
return !list(new SymlinkRetainingFileFilter(verificationRoot, openOptions)).isEmpty();
}
Expand Down Expand Up @@ -2057,7 +2053,6 @@ public List<FilePath> list() throws IOException, InterruptedException {
* @param openOptions the options to apply when opening.
* @return Direct children of this directory.
*/
@Restricted(NoExternalUse.class)
@NonNull
public List<FilePath> list(FilePath verificationRoot, OpenOption... openOptions) throws IOException, InterruptedException {
return list(new OptionalDiscardingFileFilter(verificationRoot, openOptions));
Expand Down Expand Up @@ -2222,7 +2217,6 @@ public InputStream read() throws IOException, InterruptedException {
return read(null, new OpenOption[0]);
}

@Restricted(NoExternalUse.class)
public InputStream read(FilePath rootPath, OpenOption... openOptions) throws IOException, InterruptedException {
String rootPathString = rootPath == null ? null : rootPath.remote;
if (channel == null) {
Expand All @@ -2237,7 +2231,6 @@ public InputStream read(FilePath rootPath, OpenOption... openOptions) throws IOE
return p.getIn();
}

@Restricted(NoExternalUse.class)
public static InputStream newInputStreamDenyingSymlinkAsNeeded(File file, String verificationRoot, OpenOption... openOptions) throws IOException {
InputStream inputStream = null;
try {
Expand All @@ -2254,7 +2247,6 @@ public static InputStream newInputStreamDenyingSymlinkAsNeeded(File file, String
return inputStream;
}

@Restricted(NoExternalUse.class)
public static InputStream openInputStream(File file, OpenOption[] openOptions) throws IOException {
return Files.newInputStream(fileToPath(file), stripLocalOptions(openOptions));
}
Expand Down Expand Up @@ -2290,7 +2282,6 @@ private static void denyTmpDir(File file, String root, OpenOption... openOptions
}
}

@Restricted(NoExternalUse.class)
public static boolean isSymlink(File file, String root, OpenOption... openOptions) {
if (isNoFollowLink(openOptions)) {
if (Util.isSymlink(file.toPath())) {
Expand All @@ -2306,7 +2297,6 @@ private static boolean isSymlink(VisitorInfo visitorInfo) {
return isSymlink(visitorInfo.f, visitorInfo.verificationRoot, visitorInfo.openOptions);
}

@Restricted(NoExternalUse.class)
public static boolean isTmpDir(File file, String root, OpenOption... openOptions) {
if (isIgnoreTmpDirs(openOptions)) {
if (isTmpDir(file)) {
Expand All @@ -2318,7 +2308,6 @@ public static boolean isTmpDir(File file, String root, OpenOption... openOptions
return false;
}

@Restricted(NoExternalUse.class)
public static boolean isTmpDir(String filename, OpenOption... openOptions) {
if (isIgnoreTmpDirs(openOptions)) {
return isTmpDir(filename);
Expand All @@ -2338,12 +2327,10 @@ private static boolean isTmpDir(String filename) {
return filename.length() > WorkspaceList.TMP_DIR_SUFFIX.length() && filename.endsWith(WorkspaceList.TMP_DIR_SUFFIX);
}

@Restricted(NoExternalUse.class)
public static boolean isNoFollowLink(OpenOption... openOptions) {
return Arrays.asList(openOptions).contains(LinkOption.NOFOLLOW_LINKS);
}

@Restricted(NoExternalUse.class)
public static boolean isIgnoreTmpDirs(OpenOption... openOptions) {
return Arrays.asList(openOptions).contains(DisplayOption.IGNORE_TMP_DIRS);
}
Expand Down Expand Up @@ -3713,7 +3700,6 @@ public ExplicitlySpecifiedDirScanner(Map<String, String> files) {
/**
* Wraps {@link FileVisitor} to ignore symlinks.
*/
@Restricted(NoExternalUse.class)
public static FileVisitor ignoringSymlinks(final FileVisitor v, String verificationRoot, OpenOption... openOptions) {
return validatingVisitor(FilePath::isNoFollowLink,
visitorInfo -> !isSymlink(visitorInfo),
Expand All @@ -3723,7 +3709,6 @@ public static FileVisitor ignoringSymlinks(final FileVisitor v, String verificat
/**
* Wraps {@link FileVisitor} to ignore tmp directories.
*/
@Restricted(NoExternalUse.class)
public static FileVisitor ignoringTmpDirs(final FileVisitor v, String verificationRoot, OpenOption... openOptions) {
return validatingVisitor(FilePath::isIgnoreTmpDirs,
visitorInfo -> !isTmpDir(visitorInfo),
Expand Down

0 comments on commit b91a57c

Please sign in to comment.