Add support for filesystem last modified

This commit is contained in:
Andrew Gaul 2014-07-21 12:24:44 -07:00
parent 0d77d8c2b1
commit d1bd551edf
2 changed files with 4 additions and 11 deletions

View File

@ -22,6 +22,7 @@ import static com.google.common.io.BaseEncoding.base16;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Set;
import javax.annotation.Resource;
@ -178,7 +179,8 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
public Blob getBlob(final String container, final String key) {
BlobBuilder builder = blobBuilders.get();
builder.name(key);
ByteSource byteSource = Files.asByteSource(getFileForBlobKey(container, key));
File file = getFileForBlobKey(container, key);
ByteSource byteSource = Files.asByteSource(file);
try {
builder.payload(byteSource)
.contentLength(byteSource.size())
@ -189,6 +191,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
}
Blob blob = builder.build();
blob.getMetadata().setContainer(container);
blob.getMetadata().setLastModified(new Date(file.lastModified()));
if (blob.getPayload().getContentMetadata().getContentMD5() != null)
blob.getMetadata().setETag(base16().lowerCase().encode(blob.getPayload().getContentMetadata().getContentMD5()));
return blob;

View File

@ -62,14 +62,4 @@ public class FilesystemBlobIntegrationTest extends BaseBlobIntegrationTest {
public void testCreateBlobWithExpiry() throws InterruptedException {
throw new SkipException("requires Java 7 xattr support");
}
@Override
public void testGetIfModifiedSince() throws InterruptedException {
throw new SkipException("requires Java 7 xattr support");
}
@Override
public void testGetIfUnmodifiedSince() throws InterruptedException {
throw new SkipException("requires Java 7 xattr support");
}
}