Avoid multiple resolves of the same Key (#120)

This commit is contained in:
Pavlos-Petros Tournaris 2017-02-09 00:04:45 +02:00 committed by Mike Nakhimovich
parent c9c181ed70
commit 3065d7d54f

View file

@ -30,14 +30,16 @@ public class FSReader<T> implements DiskRead<BufferedSource, T> {
@Nonnull
@Override
public Observable<BufferedSource> read(final T id) {
public Observable<BufferedSource> read(final T key) {
return Observable.fromEmitter(new Action1<Emitter<BufferedSource>>() {
@Override
public void call(Emitter<BufferedSource> emitter) {
boolean exists = fileSystem.exists(pathResolver.resolve(id));
String resolvedKey = pathResolver.resolve(key);
boolean exists = fileSystem.exists(resolvedKey);
if (exists) {
try {
BufferedSource bufferedSource = fileSystem.read(pathResolver.resolve(id));
BufferedSource bufferedSource = fileSystem.read(resolvedKey);
emitter.onNext(bufferedSource);
emitter.onCompleted();
} catch (FileNotFoundException e) {