Skip to content

Commit

Permalink
fix mkdir error when dir already exists + add better loading image
Browse files Browse the repository at this point in the history
  • Loading branch information
kfiroo committed Apr 11, 2017
1 parent 964108a commit 1ab95c8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CachedImageExample/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const styles = StyleSheet.create({
}
});

const localImage1 = require('./image1.jpg');
const localImage1 = require('./loading.jpg');

const image1 = 'https://upload.wikimedia.org/wikipedia/commons/3/3b/Big_Bog_State_Recreation_Area.jpg';
const image2 = 'https://s-media-cache-ak0.pinimg.com/originals/62/a7/6f/62a76fde4009c4e3047b4b5e17899a8d.jpg';
Expand Down
Binary file added CachedImageExample/loading.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions ImageCacheProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ function ensurePath(dirPath) {
return fs.isDir(dirPath)
.then(exists =>
!exists && fs.mkdir(dirPath)
);
)
.catch(err => {
// swallow acceptable errors
if (err.message !== 'mkdir failed, folder already exists') {
throw err;
}
});
}

/**
Expand Down Expand Up @@ -168,7 +174,6 @@ function collectFilesInfo(basePath) {
});
})
.catch(err => {
console.warn(err);
return [];
});
}
Expand Down

0 comments on commit 1ab95c8

Please sign in to comment.