Skip to content

Commit

Permalink
fix: fixed response caching functions
Browse files Browse the repository at this point in the history
These were still expecting `.perseus/`, and would've created a top-level
`cache/` directory. That'll now be created in `dist/`.
  • Loading branch information
arctic-hen7 committed Aug 20, 2022
1 parent e1c9ad3 commit e29e5d2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/perseus/src/utils/cache_res.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
/// When running automated tests, you may wish to set `force_run` to the result
/// of an environment variable check that you'll use when testing.
///
/// This function expects to be run in the context of `.perseus/`, or any
/// directory in which a folder `cache/` is available. If you're using Perseus
/// without the CLI and you don't want that directory to exist, you shouldn't
/// use this function.
///
/// # Panics
/// If this filesystem operations fail, this function will panic. It can't
/// return a graceful error since it's expected to return the type you
Expand Down Expand Up @@ -54,7 +49,7 @@ where
// In production, we'll just run the function directly
if cfg!(debug_assertions) {
// Check if the cache file exists
let filename = format!("cache/{}.json", &name);
let filename = format!("dist/cache/{}.json", &name);
match File::open(&filename).await {
Ok(mut file) => {
if force_run {
Expand Down Expand Up @@ -129,7 +124,7 @@ where
}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
// The file doesn't exist yet, create the parent cache directory
create_dir_all("cache")
create_dir_all("dist/cache")
.await
.unwrap_or_else(|err| panic!("couldn't create cache directory: {}", err));
// We have no cache, so we'll have to run the function
Expand Down

0 comments on commit e29e5d2

Please sign in to comment.