Avoid multiple resolves of the same Key (#120)
This commit is contained in:
parent
c9c181ed70
commit
3065d7d54f
1 changed files with 5 additions and 3 deletions
|
@ -30,14 +30,16 @@ public class FSReader<T> implements DiskRead<BufferedSource, T> {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Observable<BufferedSource> read(final T id) {
|
public Observable<BufferedSource> read(final T key) {
|
||||||
return Observable.fromEmitter(new Action1<Emitter<BufferedSource>>() {
|
return Observable.fromEmitter(new Action1<Emitter<BufferedSource>>() {
|
||||||
@Override
|
@Override
|
||||||
public void call(Emitter<BufferedSource> emitter) {
|
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) {
|
if (exists) {
|
||||||
try {
|
try {
|
||||||
BufferedSource bufferedSource = fileSystem.read(pathResolver.resolve(id));
|
BufferedSource bufferedSource = fileSystem.read(resolvedKey);
|
||||||
emitter.onNext(bufferedSource);
|
emitter.onNext(bufferedSource);
|
||||||
emitter.onCompleted();
|
emitter.onCompleted();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
|
Loading…
Reference in a new issue