Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<description>Standard Maven wagon support for s3:// urls</description>

<properties>
<amazonaws.version>1.11.276</amazonaws.version>
<wagon.version>3.0.0</wagon.version>
<amazonaws.version>1.11.762</amazonaws.version>
<wagon.version>3.3.4</wagon.version>
<slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version>
<junit.version>4.12</junit.version>
Expand All @@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>${amazonaws.version}</version>
<exclusions>
<exclusion>
Expand Down
15 changes: 4 additions & 11 deletions src/main/java/com/github/platform/team/plugin/AmazonS3Wagon.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,9 @@ public AmazonS3Wagon() {
this.baseDirectory = baseDirectory;
}

private static ObjectMetadata getObjectMetadata(AmazonS3 amazonS3, String bucketName, String baseDirectory,
String resourceName) {
return amazonS3.getObjectMetadata(bucketName, getKey(baseDirectory, resourceName));
}

private static String getKey(String baseDirectory, String resourceName) {
return String.format(KEY_FORMAT, baseDirectory, resourceName);
return String.format(KEY_FORMAT, baseDirectory, resourceName)
.replaceAll("/[^/]+/{1,}\\.\\./","/");
}

private static List<String> getResourceNames(ObjectListing objectListing, Pattern pattern) {
Expand Down Expand Up @@ -185,7 +181,7 @@ protected void disconnectFromRepository() {
@Override
protected boolean doesRemoteResourceExist(String resourceName) {
try {
getObjectMetadata(this.amazonS3, this.bucketName, this.baseDirectory, resourceName);
this.amazonS3.getObjectMetadata(this.bucketName, getKey(this.baseDirectory, resourceName));
return true;
} catch (AmazonServiceException e) {
return false;
Expand All @@ -195,7 +191,7 @@ protected boolean doesRemoteResourceExist(String resourceName) {
@Override
protected boolean isRemoteResourceNewer(String resourceName, long timestamp) throws ResourceDoesNotExistException {
try {
Date lastModified = getObjectMetadata(this.amazonS3, this.bucketName, this.baseDirectory, resourceName)
Date lastModified = this.amazonS3.getObjectMetadata(this.bucketName, getKey(this.baseDirectory, resourceName))
.getLastModified();
return lastModified == null || lastModified.getTime() > timestamp;
} catch (AmazonServiceException e) {
Expand Down Expand Up @@ -225,7 +221,6 @@ protected List<String> listDirectory(String directory) throws ResourceDoesNotExi
objectListing = this.amazonS3.listObjects(listObjectsRequest);
directoryContents.addAll(getResourceNames(objectListing, pattern));
}

return directoryContents;
} catch (AmazonServiceException e) {
throw new ResourceDoesNotExistException(String.format("'%s' does not exist", directory), e);
Expand All @@ -239,7 +234,6 @@ protected void getResource(String resourceName, File destination, TransferProgre
OutputStream out = null;
try {
S3Object s3Object = this.amazonS3.getObject(this.bucketName, getKey(this.baseDirectory, resourceName));

in = s3Object.getObjectContent();
out = new TransferProgressFileOutputStream(destination, transferProgress);

Expand Down Expand Up @@ -271,7 +265,6 @@ protected void putResource(File source, String destination, TransferProgress tra
objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);

in = new TransferProgressFileInputStream(source, transferProgress);

this.amazonS3.putObject(new PutObjectRequest(this.bucketName, key, in, objectMetadata));
} catch (AmazonServiceException e) {
throw new TransferFailedException(String.format("Cannot write file to '%s'", destination), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,17 @@ public final void putDirectory(File sourceDirectory, String destinationDirectory
File[] files = sourceDirectory.listFiles();
if (files != null) {
for (File f : files) {
put(f, destinationDirectory + "/" + f.getName());
String name;
if (destinationDirectory.equals("./")) {
name = f.getName();
} else {
name = destinationDirectory + "/" + f.getName();
}
if (f.isFile()) {
put(f, name);
} else if (f.isDirectory()) {
putDirectory(f, name);
}
}
}
}
Expand Down