GitDBRepo.readValue now returns String

This commit is contained in:
Paul Campbell 2018-06-14 07:32:58 +01:00
parent f2ee721ec4
commit ffc2b56b05
2 changed files with 4 additions and 4 deletions

View file

@ -79,8 +79,7 @@ public class GitDBBranch {
* @throws IOException if there was an error reading the value
*/
public Optional<String> get(final String key) throws IOException {
return gitDBRepo.readValue(branchRef, KEY_PREFIX + key)
.map(String::new);
return gitDBRepo.readValue(branchRef, KEY_PREFIX + key);
}
/**

View file

@ -165,14 +165,15 @@ class GitDBRepo {
* @return an Optional containing the value if found, or empty
* @throws IOException if there was an error reading the value
*/
Optional<byte[]> readValue(
Optional<String> readValue(
final Ref branchRef,
final String key
) throws IOException {
try (TreeWalk treeWalk = getTreeWalk(branchRef)) {
treeWalk.setFilter(PathFilter.create(key));
if (treeWalk.next()) {
return Optional.of(repository.open(treeWalk.getObjectId(0), Constants.OBJ_BLOB).getBytes());
return Optional.of(new String(
repository.open(treeWalk.getObjectId(0), Constants.OBJ_BLOB).getBytes()));
}
}
return Optional.empty();