diff --git a/README.md b/README.md index bc82832..6dec179 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Plexus-IO [![Build Status](https://github.com/codehaus-plexus/plexus-io/actions/workflows/maven.yml/badge.svg)](https://github.com/codehaus-plexus/plexus-io/actions/workflows/maven.yml) [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-io.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.plexus/plexus-io) +[![Reproducible Builds](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jvm-repo-rebuild/reproducible-central/master/content/org/codehaus/plexus/plexus-io/badge.json)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/codehaus/plexus/plexus-io/README.md) The current master is now at https://github.com/codehaus-plexus/plexus-io @@ -11,14 +12,3 @@ For publishing [the site](https://codehaus-plexus.github.io/plexus-io/) do the f ``` mvn -Preporting verify site-deploy ``` - -## Release Notes - -You can find details about the different releases in the -[Release Notes](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md). - - * [Release 3.2.0](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md#plexus-io-320). - * [Release 3.1.1](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md#plexus-io-311). - * [Release 3.1.0](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md#plexus-io-310). - * [Release 3.0.1](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md#plexus-io-301). - * [Release 3.0.0](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md#plexus-io-300). diff --git a/ReleaseNotes.md b/ReleaseNotes.md deleted file mode 100644 index 70c0095..0000000 --- a/ReleaseNotes.md +++ /dev/null @@ -1,243 +0,0 @@ -Plexus-IO Release Notes -======================================================================== - -Plexus IO 3.2.0 ---------------- - -Plexus IO 3.2.0 requires Java 7. - -### New Features - - * [Issue #18][issue-18] - Add an option to sort the entries of PlexusIoFileResourceCollection - -Plexus IO 3.1.1 ---------------- - -Plexus IO 3.1.1 requires Java 7. - -### Improvements - - * [Issue #16][issue-16], [Pull Request #17][pr-17] - Improve performance - on systems which have high time penalty when fetching owner and group name. - Thanks to Classe. - -Plexus IO 3.1.0 ---------------- - -Plexus IO 3.1.0 requires Java 7. - -### New Features - - * [Pull Request #14][pr-14] - Add new FileMapper for giving a suffix to filename: - `SuffixFileMapper`. Thanks to Thomas Collignon. - -Plexus IO 3.0.1 ---------------- - -Plexus IO 3.0.1 requires Java 7. - -### Tasks - - * [Issue #9][issue-9], [Issue #10][issue-10] - Updated dependencies: - `plexus-utils` to 3.1.0 and `commons-io` to 2.6 - -Plexus IO 3.0.0 ---------------- - -Plexus IO 3.0.0 requires Java 7 and introduces backward incompatible changes: - - * `Java7FileAttributes` is renamed to `FileAttributes`, replacing - the old `FileAttributes` implementation - * `Java7AttributeUtils` is renamed to `AttributeUtils` - * `PlexusIoResourceAttributeUtils#getFileAttributesByPath( File, boolean, boolean )` - is deleted - -### Improvements - - * [Pull Request #5][pr-5] - The required Java version is upgraded to 7. - Classes that use native tools like `ls` are removed and the pure Java - implementations are used instead. - -### Tasks - - * [Issue #8][issue-8] - Update of `plexus-utils` to 3.0.24 and - `commons-io` to 2.5 - -Plexus IO 2.7.1 ---------------- - -### Improvements - - * [Pull Request #3][pr-3] - Introduce new constant to indicate uknown - octal mode for resources - `PlexusIoResourceAttributes.UNKNOWN_OCTAL_MODE` - -### Bugs - - * [Issue #2][issue-2] - JAR entry not found when JAR is updated inline and - cached by URLConnection - -Plexus IO 2.7 ---------------- - -### Improvements - - * Added TIME_STYLE=long-iso to ls screen scrape - * [Pull Request #1][pr-1] - Add concurrent access flag - to the PlexusIoProxyResourceCollection - - `PlexusIoResourceCollection#isConcurrentAccessSupported()` - -Plexus IO 2.6.1 ---------------- - -### Improvement - - * Performance improvement affecting mac/linux users - with lots of small files in large archives. - -Plexus IO 2.5 -------------- - - * Proper support for closeable on zip archives. - * Removed zip supporting PlexusIoZipFileResourceCollection; which now exists in plexus-archiver. (Drop in replacement, - just change/add jar file). - -Plexus IO 2.4.1 ---------------- - -### Bugs - - * PLXCOMP-279 - PlexusIoProxyResourceCollection does not provide Closeable iterator - * Fixed PLXCOMP-280 - SimpleResourceAttributes has incorrect value for - default file mode - -Plexus IO 2.4 -------------- - -### Improvements - - * PLXCOMP-274 - Simplify use of proxies - * PLXCOMP-275 - Avoid leaky abstractions - * PLXCOMP-276 - Reduce number of ways to create a PlexusIoResource - -Plexus IO 2.3.5 ---------------- - -### Bugs - - * PLXCOMP-278 - Symlink attribute was not preserved through merged/overridden attributes - -Plexus IO 2.3.4 ---------------- - -### Bugs - - * PLXCOMP-270 - Escaping algoritghm leaks through to system classloader - * PLXCOMP-272 - Overriding dirmode/filemode breaks symlinks - -Plexus IO 2.3.3 ---------------- - -### Bugs - - * PLXCOMP-267 - StreamTransformers are consistently applied to all collections - -Plexus IO 2.3.2 ---------------- - -### Bugs - - * PLXCOMP-265 - Locale in shell influences "ls" parsing for screenscraper - -Plexus IO 2.3.1 ---------------- - -### Bugs - - * PLXCOMP-264 - Thread safety issue in streamconsumer - -Plexus IO 2.3 -------------- - -### New Features - - * PLXCOMP-261 - Make plexus io collections support on-the-fly filtering - -### Improvements - - * PLXCOMP-260 - Make plexus io collections iterable - -Plexus IO 2.2 -------------- - -### Bugs - - * PLXCOMP-251 - Date parsing in "ls" screenscraping has locale dependencies - * PLXCOMP-254 - Fix File.separatorChar normalization when prefixes are used - -Plexus IO 2.1.4 ---------------- - -### Improvements - - * PLXCOMP-250 - Upgrade maven-enforcer-plugin to 1.3.1 - -### Bugs - - * PLXCOMP-107 - Fail to unzip archive, which contains file with name - 'How_can_I_annotate_a_part_in_the_AAM%3F.Help' - -Plexus IO 2.1.3 ---------------- - -### Bugs - - * PLXCOMP-247 - Bug with windows AND java5 - -Plexus IO 2.1.2 ---------------- - -### Bugs - - * PLXCOMP-244 - Don't try to set attributes of symbolic links - * PLXCOMP-245 - Archives created on windows get zero permissions, - creates malformed permissions on linux - -Plexus IO 2.1.1 ---------------- - -### Bugs - - * PLXCOMP-243 - Restore JDK1.5 compatibility - -Plexus IO 2.1 -------------- - -### Improvements - - * PLXCOMP-64 - add symlink support to tar unarchiver - * PLXCOMP-117 - add symbolic links managment - -### Bugs - - * PLXCOMP-113 - zip unarchiver doesn't support symlinks (and trivial to fix) - * PLXCOMP-241 - ResourcesTest.compare test failure - * PLXCOMP-248 - Use java7 setAttributes and ignore useJvmChmod flag when applicable - -Plexus IO 2.0.12 ----------------- - -### Bugs - - * PLXCOMP-249 - Add support for java7 chmod - -[issue-2]: https://github.com/codehaus-plexus/plexus-io/issues/2 -[issue-8]: https://github.com/codehaus-plexus/plexus-io/issues/8 -[issue-9]: https://github.com/codehaus-plexus/plexus-io/issues/9 -[issue-10]: https://github.com/codehaus-plexus/plexus-io/issues/10 -[issue-16]: https://github.com/codehaus-plexus/plexus-io/issues/16 -[issue-18]: https://github.com/codehaus-plexus/plexus-io/issues/18 -[pr-1]: https://github.com/codehaus-plexus/plexus-io/pull/1 -[pr-3]: https://github.com/codehaus-plexus/plexus-io/pull/3 -[pr-5]: https://github.com/codehaus-plexus/plexus-io/pull/5 -[pr-14]: https://github.com/codehaus-plexus/plexus-io/pull/14 -[pr-17]: https://github.com/codehaus-plexus/plexus-io/pull/17 diff --git a/pom.xml b/pom.xml index 518f28c..d2ef943 100644 --- a/pom.xml +++ b/pom.xml @@ -9,14 +9,14 @@ plexus-io - 3.5.0 + 3.5.1 Plexus IO Components scm:git:git@github.com:codehaus-plexus/plexus-io.git scm:git:git@github.com:codehaus-plexus/plexus-io.git - plexus-io-3.5.0 + plexus-io-3.5.1 http://github.com/codehaus-plexus/plexus-io @@ -33,7 +33,7 @@ 0.9.0.M3 1.7.36 - 2024-07-04T12:25:59Z + 2024-09-09T12:59:16Z @@ -96,7 +96,7 @@ org.codehaus.plexus plexus-testing - 1.3.0 + 1.4.0 test diff --git a/src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java b/src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java index 94c0d3c..d530790 100644 --- a/src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java +++ b/src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; @@ -28,9 +29,10 @@ import java.nio.file.attribute.PosixFilePermission; import java.security.Principal; import java.util.Collections; -import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.WeakHashMap; +import java.util.concurrent.ConcurrentHashMap; /* * File attributes @@ -68,6 +70,12 @@ public class FileAttributes implements PlexusIoResourceAttributes { private final FileTime lastModifiedTime; + private static final Map> UIDS_CACHE = + Collections.synchronizedMap(new WeakHashMap<>()); + + private static final Map> GIDS_CACHE = + Collections.synchronizedMap(new WeakHashMap<>()); + /** * @deprecated use {@link #FileAttributes(File)} and remove the unused userCache and groupCache parameters */ @@ -79,32 +87,64 @@ public FileAttributes( } public FileAttributes(@Nonnull File file) throws IOException { - this(file, false); + this(file.toPath(), false); } public FileAttributes(@Nonnull File file, boolean followLinks) throws IOException { + this(file.toPath(), followLinks); + } + + private static Map getUserCache(FileSystem fs) { + return UIDS_CACHE.computeIfAbsent(fs, f -> new ConcurrentHashMap<>()); + } + + private static Map getGroupCache(FileSystem fs) { + return GIDS_CACHE.computeIfAbsent(fs, f -> new ConcurrentHashMap<>()); + } + + public FileAttributes(@Nonnull Path path, boolean followLinks) throws IOException { LinkOption[] options = followLinks ? FOLLOW_LINK_OPTIONS : NOFOLLOW_LINK_OPTIONS; - Path path = file.toPath(); Set views = path.getFileSystem().supportedFileAttributeViews(); String names; if (views.contains("unix")) { - names = "unix:*"; + names = + "unix:gid,uid,isSymbolicLink,isRegularFile,isDirectory,isOther,mode,permissions,size,lastModifiedTime"; } else if (views.contains("posix")) { names = "posix:*"; } else { names = "basic:*"; } Map attrs = Files.readAttributes(path, names, options); - if (!attrs.containsKey("group") && !attrs.containsKey("owner") && views.contains("owner")) { - Map ownerAttrs = Files.readAttributes(path, "owner:*", options); - Map newAttrs = new HashMap<>(attrs); - newAttrs.putAll(ownerAttrs); - attrs = newAttrs; - } this.groupId = (Integer) attrs.get("gid"); - this.groupName = attrs.containsKey("group") ? ((Principal) attrs.get("group")).getName() : null; + if (attrs.containsKey("group")) { + this.groupName = ((Principal) attrs.get("group")).getName(); + } else if (this.groupId != null) { + Map cache = getGroupCache(path.getFileSystem()); + String name = cache.get(this.groupId); + if (name == null) { + name = getPrincipalName(path, "unix:group"); + cache.put(this.groupId, name); + } + this.groupName = name; + } else { + this.groupName = null; + } this.userId = (Integer) attrs.get("uid"); - this.userName = attrs.containsKey("owner") ? ((Principal) attrs.get("owner")).getName() : null; + if (attrs.containsKey("owner")) { + this.userName = ((Principal) attrs.get("owner")).getName(); + } else if (this.userId != null) { + Map cache = getUserCache(path.getFileSystem()); + String name = cache.get(this.userId); + if (name == null) { + name = getPrincipalName(path, "unix:owner"); + cache.put(this.userId, name); + } + this.userName = name; + } else if (views.contains("owner")) { + this.userName = getPrincipalName(path, "owner:owner"); + } else { + this.userName = null; + } this.symbolicLink = (Boolean) attrs.get("isSymbolicLink"); this.regularFile = (Boolean) attrs.get("isRegularFile"); this.directory = (Boolean) attrs.get("isDirectory"); @@ -120,6 +160,11 @@ public FileAttributes(@Nonnull File file, boolean followLinks) throws IOExceptio this.lastModifiedTime = (FileTime) attrs.get("lastModifiedTime"); } + private static String getPrincipalName(Path path, String attribute) throws IOException { + Object owner = Files.getAttribute(path, attribute, LinkOption.NOFOLLOW_LINKS); + return ((Principal) owner).getName(); + } + public FileAttributes( @Nullable Integer userId, String userName, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy