Skip to content

Commit

Permalink
fix: remove BlockRemover from BlockReader
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Peterson <[email protected]>
  • Loading branch information
mattp-swirldslabs committed Aug 5, 2024
1 parent d3b4978 commit 444a61c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ public class BlockAsDirReader implements BlockReader<Block> {

private final Path blockNodeRootPath;
private final FileAttribute<Set<PosixFilePermission>> filePerms;
private final BlockRemover blockRemover;

public BlockAsDirReader(
final String key,
final Config config,
final BlockRemover blockRemover,
final FileAttribute<Set<PosixFilePermission>> filePerms) {

LOGGER.log(System.Logger.Level.INFO, "Initializing FileSystemBlockReader");
Expand All @@ -55,16 +53,11 @@ public BlockAsDirReader(
LOGGER.log(System.Logger.Level.INFO, "Block Node Root Path: " + blockNodeRootPath);

this.blockNodeRootPath = blockNodeRootPath;
this.blockRemover = blockRemover;
this.filePerms = filePerms;
}

public BlockAsDirReader(final String key, final Config config) {
this(
key,
config,
new BlockAsDirRemover(Path.of(config.get(key).asString().get()), Util.defaultPerms),
Util.defaultPerms);
this(key, config, Util.defaultPerms);
}

@Override
Expand Down Expand Up @@ -109,8 +102,6 @@ public Optional<Block> read(final long blockNumber) throws IOException {
return Optional.of(builder.build());
} catch (IOException io) {
LOGGER.log(System.Logger.Level.ERROR, "Error reading block: " + blockPath, io);
LOGGER.log(System.Logger.Level.ERROR, "Attempting to remove the block: " + blockPath);
blockRemover.remove(blockNumber);

throw io;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testRemoveBlockReadPermsRepairFailed() throws IOException {
new BlockAsDirRemover(
Path.of(testConfig.get(JUNIT).asString().get()), Util.defaultPerms);
final BlockReader<Block> blockReader =
new BlockAsDirReader(JUNIT, testConfig, blockRemover, TestUtils.getNoPerms());
new BlockAsDirReader(JUNIT, testConfig, TestUtils.getNoPerms());
final Optional<Block> blockOpt = blockReader.read(1);
assertTrue(blockOpt.isEmpty());
}
Expand Down

0 comments on commit 444a61c

Please sign in to comment.