From c46f74be9110bef768acdd8ca234920a03cc2311 Mon Sep 17 00:00:00 2001 From: Francisco Guerrero Date: Mon, 9 Oct 2023 03:06:09 -0700 Subject: [PATCH] Add file store name to the FileSystemProps interface (#4886) The file store name is part of the `java.nio.file.FileStore` object which is used to build the `io.vertx.core.file.impl.FileSystemPropsImpl` object. However, the name is not defined as part of the `io.vertx.core.file.FileSystemProps` interface. This piece of information is important including when logging information about the `io.vertx.core.file.FileSystemProps` concrete object when consuming it through `vertx.fileSystem().fsProps()` calls. --- src/main/java/io/vertx/core/file/FileSystemProps.java | 5 +++++ .../java/io/vertx/core/file/impl/FileSystemImpl.java | 5 +---- .../io/vertx/core/file/impl/FileSystemPropsImpl.java | 9 ++++++++- src/test/java/io/vertx/core/file/FileSystemTest.java | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/vertx/core/file/FileSystemProps.java b/src/main/java/io/vertx/core/file/FileSystemProps.java index 1af0a468503..e18b54b2dcd 100644 --- a/src/main/java/io/vertx/core/file/FileSystemProps.java +++ b/src/main/java/io/vertx/core/file/FileSystemProps.java @@ -22,6 +22,11 @@ @VertxGen public interface FileSystemProps { + /** + * @return The name of this file store + */ + String name(); + /** * @return The total space on the file system, in bytes */ diff --git a/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java b/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java index 397510713ca..9894bc94df7 100644 --- a/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java +++ b/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java @@ -12,10 +12,7 @@ package io.vertx.core.file.impl; import io.vertx.codegen.annotations.Nullable; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; -import io.vertx.core.Promise; import io.vertx.core.buffer.Buffer; import io.vertx.core.file.AsyncFile; import io.vertx.core.file.CopyOptions; @@ -959,7 +956,7 @@ public FileSystemProps perform() { try { Path target = vertx.resolveFile(path).toPath(); FileStore fs = Files.getFileStore(target); - return new FileSystemPropsImpl(fs.getTotalSpace(), fs.getUnallocatedSpace(), fs.getUsableSpace()); + return new FileSystemPropsImpl(fs.name(), fs.getTotalSpace(), fs.getUnallocatedSpace(), fs.getUsableSpace()); } catch (IOException e) { throw new FileSystemException(getFileAccessErrorMessage("analyse", path), e); } diff --git a/src/main/java/io/vertx/core/file/impl/FileSystemPropsImpl.java b/src/main/java/io/vertx/core/file/impl/FileSystemPropsImpl.java index 0b4311194e8..7d68e24f1ee 100644 --- a/src/main/java/io/vertx/core/file/impl/FileSystemPropsImpl.java +++ b/src/main/java/io/vertx/core/file/impl/FileSystemPropsImpl.java @@ -15,16 +15,23 @@ public class FileSystemPropsImpl implements FileSystemProps { + private final String name; private final long totalSpace; private final long unallocatedSpace; private final long usableSpace; - public FileSystemPropsImpl(long totalSpace, long unallocatedSpace, long usableSpace) { + public FileSystemPropsImpl(String name, long totalSpace, long unallocatedSpace, long usableSpace) { + this.name = name; this.totalSpace = totalSpace; this.unallocatedSpace = unallocatedSpace; this.usableSpace = usableSpace; } + @Override + public String name() { + return name; + } + @Override public long totalSpace() { return totalSpace; diff --git a/src/test/java/io/vertx/core/file/FileSystemTest.java b/src/test/java/io/vertx/core/file/FileSystemTest.java index 250ffec63ce..dad3f119291 100644 --- a/src/test/java/io/vertx/core/file/FileSystemTest.java +++ b/src/test/java/io/vertx/core/file/FileSystemTest.java @@ -1603,6 +1603,7 @@ public void testFSProps() throws Exception { String fileName = "some-file.txt"; createFileWithJunk(fileName, 1234); testFSProps(fileName, props -> { + assertNotNull(props.name()); assertTrue(props.totalSpace() > 0); assertTrue(props.unallocatedSpace() > 0); assertTrue(props.usableSpace() > 0);