Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alice-open-data: Replace deprecated env::home_dir with dirs crate #4

Merged
merged 1 commit into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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