Permalink
Browse files

Increase performance of uploads to s3 by avoiding downloading metadat…

…a when possible
  • Loading branch information...
1 parent 3588ccc commit 8bce9221208a07fff712f40e0214696ff10aa27e @jamessanders committed Jan 20, 2013
@@ -61,7 +61,8 @@ public static void copy(IResource in, IResource out) throws IOException {
}
private static boolean filesDiffer(IResource f1, IResource f2) {
- return (f1.lastModified() > f2.lastModified() || f1.getSize() != f2.getSize());
+ boolean datesDiffer = (f1.lastModified() > f2.lastModified() && f1.getModifiedTime() > f2.getModifiedTime());
+ return (datesDiffer || f1.getSize() != f2.getSize());
}
public static void performDeletions(IResource source, IResource destination, IResource backup) {
@@ -238,6 +238,7 @@ public void deleteObject(S3Resource resource) {
}
public ObjectMetadata getObjectMetadata(S3Resource resource) {
+
return client.getObjectMetadata(this.getBucket(), resource.getKey());
}
@@ -155,21 +155,14 @@ public void delete() {
}
public long lastModified() {
- ObjectMetadata metadata = this.getS3Metadata();
- String mtime = metadata.getUserMetadata().get("mtime");
- if (mtime != null) {
- return (new Date(Long.parseLong(mtime))).getTime()*1000;
- } else if (s3ObjectSummary == null) {
- Date lastModifed = getS3Metadata().getLastModified();
- if (lastModifed != null) {
- System.err.println("Using current time as last modifed");
- return lastModifed.getTime();
- } else {
- return 0;
+ long lmod = 0;
+ if (s3ObjectSummary != null) {
+ Date lastModified = this.s3ObjectSummary.getLastModified();
+ if (lastModified != null) {
+ lmod = lastModified.getTime();
}
- } else {
- return s3ObjectSummary.getLastModified().getTime();
}
+ return lmod;
}
public ObjectMetadata getS3Metadata() {

0 comments on commit 8bce922

Please sign in to comment.