Skip to content

Commit 59c7470

Browse files
author
Plamen Totev
committed
Add addSynchronously flag to ArchiveEntry
plexus-io 2.7 adds support for resource collection that does not allow concurrent access to it's entries. Add flag to ArchiveEntry so archiver implementations could know that they should add entries form such collections synchronously.
1 parent 6484ebb commit 59c7470

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/org/codehaus/plexus/archiver/ArchiveEntry.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class ArchiveEntry
6060

6161
private PlexusIoResourceAttributes attributes;
6262

63+
private final boolean addSynchronously;
64+
6365
/**
6466
* @param name the filename as it will appear in the archive. This is platform-specific
6567
* normalized with File.separatorChar
@@ -92,6 +94,8 @@ private ArchiveEntry( String name, @Nonnull PlexusIoResource resource, int type,
9294

9395
this.mode = permissions == -1 ? permissions : ( permissions & UnixStat.PERM_MASK ) |
9496
( type == FILE ? UnixStat.FILE_FLAG : type == SYMLINK ? UnixStat.LINK_FLAG : UnixStat.DIR_FLAG );
97+
98+
this.addSynchronously = ( collection != null && !collection.isConcurrentAccessSupported() );
9599
}
96100

97101
/**
@@ -154,6 +158,17 @@ public int getMode()
154158
( type == FILE ? UnixStat.FILE_FLAG : type == SYMLINK ? UnixStat.LINK_FLAG : UnixStat.DIR_FLAG );
155159
}
156160

161+
/**
162+
* Indicates if this entry should be added to the archive synchronously
163+
* before adding the next entry and/or accessing the next entry of {@link ResourceIterator}.
164+
*
165+
* @return {@code true} if this entry should be added synchronously
166+
*/
167+
public boolean shouldAddSynchronously()
168+
{
169+
return addSynchronously;
170+
}
171+
157172
public static ArchiveEntry createFileEntry( String target, PlexusIoResource resource, int permissions,
158173
PlexusIoResourceCollection collection, int defaultDirectoryPermissions )
159174
throws ArchiverException

0 commit comments

Comments
 (0)