Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAP-204 oap-cloud: FileSystem#getMetadata #328

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ public void testGetMetadata() {
s3mockFixture.uploadFile( TEST_BUCKET, "logs/file.txt", path, Map.of( "test-tag", "tag-val" ) );

FileSystem.StorageItem item = fileSystem.getMetadata( new CloudURI( "s3", TEST_BUCKET, "/logs/file.txt" ) );

assertThat( item.getLastModified() ).isLessThanOrEqualTo( new DateTime( DateTimeZone.UTC ) );
assertThat( item.getSize() ).isEqualTo( 11L );

assertThat( fileSystem.getMetadata( new CloudURI( "s3", TEST_BUCKET, "/unknown.txt" ) ) ).isNull();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.joda.time.DateTime;

import javax.annotation.Nullable;
import java.io.File;
import java.io.InputStream;
import java.io.Serial;
Expand Down Expand Up @@ -352,12 +353,17 @@ public PageSet<? extends StorageItem> list( String path, ListContainerOptions op
return list( pathURI, options );
}

@Nullable
public StorageItem getMetadata( CloudURI path ) {
log.debug( "getMetadata {}", path );

try( BlobStoreContext context = getContext( path ) ) {
BlobStore blobStore = context.getBlobStore();
return wrapToStorageItem( blobStore.getBlob( path.container, path.path ).getMetadata() );
Blob blob = blobStore.getBlob( path.container, path.path );
if( blob == null ) {
return null;
}
return wrapToStorageItem( blob.getMetadata() );
} catch( Exception e ) {
throw new CloudException( e );
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</distributionManagement>

<properties>
<oap.project.version>22.4.17</oap.project.version>
<oap.project.version>22.4.18</oap.project.version>

<oap.deps.config.version>21.0.0</oap.deps.config.version>
<oap.deps.oap-teamcity.version>21.0.1</oap.deps.oap-teamcity.version>
Expand Down
Loading