From 3065d7d54f9605e1a2bbc97f4a7e89923e6b100e Mon Sep 17 00:00:00 2001
From: Pavlos-Petros Tournaris
Date: Thu, 9 Feb 2017 00:04:45 +0200
Subject: [PATCH] Avoid multiple resolves of the same Key (#120)
---
.../java/com/nytimes/android/external/fs/FSReader.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/filesystem/src/main/java/com/nytimes/android/external/fs/FSReader.java b/filesystem/src/main/java/com/nytimes/android/external/fs/FSReader.java
index ab3833b..c76ee1e 100644
--- a/filesystem/src/main/java/com/nytimes/android/external/fs/FSReader.java
+++ b/filesystem/src/main/java/com/nytimes/android/external/fs/FSReader.java
@@ -30,14 +30,16 @@ public class FSReader implements DiskRead {
@Nonnull
@Override
- public Observable read(final T id) {
+ public Observable read(final T key) {
return Observable.fromEmitter(new Action1>() {
@Override
public void call(Emitter 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) {