Skip to content

Commit 3c5fc72

Browse files
committed
Set chmod to files AND directories
1 parent 6f917f9 commit 3c5fc72

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/main/java/org/codehaus/plexus/archiver/dir/DirectoryArchiver.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
import org.codehaus.plexus.archiver.ResourceIterator;
2323
import org.codehaus.plexus.archiver.util.ArchiveEntryUtils;
2424
import org.codehaus.plexus.archiver.util.ResourceUtils;
25+
import org.codehaus.plexus.archiver.UnixStat;
2526
import org.codehaus.plexus.components.io.attributes.SymlinkUtils;
2627
import org.codehaus.plexus.components.io.functions.SymlinkDestinationSupplier;
2728
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
2829

30+
import java.nio.file.Path;
31+
import java.nio.file.Paths;
2932
import java.io.File;
3033
import java.io.IOException;
3134

@@ -141,11 +144,6 @@ protected void copyFile( final ArchiveEntry entry, final String vPath )
141144
}
142145
}
143146
ResourceUtils.copyFile( entry.getInputStream(), outFile );
144-
145-
if ( !isIgnorePermissions() )
146-
{
147-
ArchiveEntryUtils.chmod( outFile, entry.getMode(), getLogger(), isUseJvmChmod() );
148-
}
149147
}
150148
else
151149
{ // file is a directory
@@ -166,6 +164,15 @@ else if ( !outFile.mkdirs() )
166164
}
167165
}
168166

167+
if ( !isIgnorePermissions() )
168+
{
169+
// compute relative path
170+
String relative = outFile.getAbsolutePath().replaceFirst(getDestFile().getAbsolutePath(), ".");
171+
getLogger().info( "Set chmod " + Integer.toOctalString( 0x0fff & entry.getMode() ) + " for " + relative );
172+
// call chmod (java or system)
173+
ArchiveEntryUtils.chmod( outFile, entry.getMode(), getLogger(), isUseJvmChmod() );
174+
}
175+
169176
outFile.setLastModified( inLastModified == PlexusIoResource.UNKNOWN_MODIFICATION_DATE ? System.currentTimeMillis()
170177
: inLastModified );
171178
}

0 commit comments

Comments
 (0)