summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satserver
diff options
context:
space:
mode:
authorSimon Rettberg2020-11-03 13:49:36 +0100
committerSimon Rettberg2020-11-03 13:49:36 +0100
commitb8176ffbba9b6c0849e3da075f0d4a3cfca6e092 (patch)
treeb116eb05e30a11577a584cd6f7ec3783eafe393e /src/main/java/org/openslx/satserver
parent[WakeOnLan] Make dest port configurable (diff)
downloadtmlite-bwlp-b8176ffbba9b6c0849e3da075f0d4a3cfca6e092.tar.gz
tmlite-bwlp-b8176ffbba9b6c0849e3da075f0d4a3cfca6e092.tar.xz
tmlite-bwlp-b8176ffbba9b6c0849e3da075f0d4a3cfca6e092.zip
[RecompressArchive] Properly implement duplicate filename detection
Implements #3670
Diffstat (limited to 'src/main/java/org/openslx/satserver')
-rw-r--r--src/main/java/org/openslx/satserver/util/Archive.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/satserver/util/Archive.java b/src/main/java/org/openslx/satserver/util/Archive.java
index 8ad2123..25285e7 100644
--- a/src/main/java/org/openslx/satserver/util/Archive.java
+++ b/src/main/java/org/openslx/satserver/util/Archive.java
@@ -28,6 +28,7 @@ import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
public class Archive
{
@@ -102,13 +103,27 @@ public class Archive
public static TarArchiveEntry createTarArchiveEntry( ArchiveEntry inEntry, int defaultUser, int defaultGroup, int defaultDirMode, int defaultFileMode )
{
- if ( inEntry instanceof TarArchiveEntry ) {
- // Source is tar - easy
- return (TarArchiveEntry)inEntry;
+ String name = inEntry.getName();
+ if ( Util.isEmpty( name ) )
+ return null;
+ if ( !name.startsWith( "/" ) ) {
+ name = "/" + name;
}
- final TarArchiveEntry outEntry = new TarArchiveEntry( inEntry.getName() );
+ name = FilenameUtils.normalize( name );
+ if ( name == null )
+ return null;
+ if ( Util.isEmpty( name ) )
+ return null;
+ final TarArchiveEntry outEntry = new TarArchiveEntry( name );
outEntry.setSize( inEntry.getSize() );
- if ( inEntry instanceof ArArchiveEntry ) {
+ if ( inEntry instanceof TarArchiveEntry ) {
+ // Source is tar - easy
+ outEntry.setUserName( ( (TarArchiveEntry)inEntry ).getUserName() );
+ outEntry.setGroupName( ( (TarArchiveEntry)inEntry ).getGroupName() );
+ outEntry.setIds( ( (TarArchiveEntry)inEntry ).getUserId(), ( (TarArchiveEntry)inEntry ).getGroupId() );
+ outEntry.setMode( ( (TarArchiveEntry)inEntry ).getMode() );
+ outEntry.setModTime( ( (TarArchiveEntry)inEntry ).getLastModifiedDate() );
+ } else if ( inEntry instanceof ArArchiveEntry ) {
// Source is ar - has most of the stuff tar supports; transform
outEntry.setIds( ( (ArArchiveEntry)inEntry ).getUserId(), ( (ArArchiveEntry)inEntry ).getGroupId() );
outEntry.setMode( ( (ArArchiveEntry)inEntry ).getMode() );