Skip to content

Commit

Permalink
alice-open-data: Replace deprecated env::home_dir with dirs crate
Browse files Browse the repository at this point in the history
  • Loading branch information
akubera committed Dec 20, 2018
1 parent 7d2a48e commit 893a1d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions alice-open-data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ license = "MPL-2.0"
glob = "^0.2.11"
failure = "0.1.1"
reqwest = "0.8.5"
dirs = "1.0"
10 changes: 5 additions & 5 deletions alice-open-data/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[macro_use]
extern crate failure;
extern crate dirs;
extern crate glob;
extern crate reqwest;

use std::env;
use std::io::{Read};
use std::path::PathBuf;
use std::fs::{DirBuilder, File};
Expand Down Expand Up @@ -36,7 +36,7 @@ pub fn download(base_dir: PathBuf, url: Url) -> Result<u64, Error> {

/// Base path to the local ALICE open data directory
pub fn data_dir() -> Result<PathBuf, Error> {
let mut dir = env::home_dir().ok_or(format_err!("No home directory"))?;
let mut dir = dirs::home_dir().ok_or(format_err!("No home directory"))?;
dir.push("lhc_open_data");
Ok(dir)
}
Expand Down Expand Up @@ -94,7 +94,7 @@ fn download_with_https(uri: Url) -> Result<reqwest::Response, Error> {

#[cfg(test)]
mod tests {
use std::fs;
use std::{fs, env};
#[test]
fn test_get_file_lists() {
let runs = [
Expand All @@ -121,13 +121,13 @@ mod tests {
let uri = super::get_file_list(139038).unwrap()[0].clone();
{
// Remobe old stuff:
let mut dir = super::env::temp_dir();
let mut dir = env::temp_dir();
dir.push("eos");
if dir.exists() {
fs::remove_dir_all(dir).unwrap();
}
}
let base_dir = super::env::temp_dir();
let base_dir = env::temp_dir();
// Download if file does not exist
assert_eq!(super::download(base_dir.clone(), uri.clone()).unwrap(), 14283265);
// Don't download twice
Expand Down

0 comments on commit 893a1d7

Please sign in to comment.