match *local {
LocalFingerprint::MtimeBased(ref slot, ref path) => {
let path = root.join(path);
- let meta = fs::metadata(&path)
- .chain_err(|| internal(format!("failed to stat `{}`", path.display())))?;
- let mtime = FileTime::from_last_modification_time(&meta);
+ let mtime = paths::mtime(&path)?;
*slot.0.lock().unwrap() = Some(mtime);
}
LocalFingerprint::EnvBased(..) | LocalFingerprint::Precalculated(..) => continue,
I: IntoIterator,
I::Item: AsRef<Path>,
{
- let meta = match fs::metadata(output) {
- Ok(meta) => meta,
+ let mtime = match paths::mtime(output) {
+ Ok(mtime) => mtime,
Err(..) => return None,
};
- let mtime = FileTime::from_last_modification_time(&meta);
let any_stale = paths.into_iter().any(|path| {
let path = path.as_ref();
- let meta = match fs::metadata(path) {
- Ok(meta) => meta,
+ let mtime2 = match paths::mtime(path) {
+ Ok(mtime) => mtime,
Err(..) => {
info!("stale: {} -- missing", path.display());
return true;
}
};
- let mtime2 = FileTime::from_last_modification_time(&meta);
if mtime2 > mtime {
info!("stale: {} -- {} vs {}", path.display(), mtime2, mtime);
true
use core::{Dependency, Package, PackageId, Registry, Source, SourceId, Summary};
use ops;
use util::{self, internal, CargoResult};
+use util::paths;
use util::Config;
pub struct PathSource<'cfg> {
// condition where this path was rm'ed - either way,
// we can ignore the error and treat the path's mtime
// as 0.
- let mtime = fs::metadata(&file)
- .map(|meta| FileTime::from_last_modification_time(&meta))
- .unwrap_or(FileTime::zero());
+ let mtime = paths::mtime(&file).unwrap_or(FileTime::zero());
warn!("{} {}", mtime, file.display());
if mtime > max {
max = mtime;
use std::io::prelude::*;
use std::path::{Component, Path, PathBuf};
+use filetime::FileTime;
+
use util::{internal, CargoResult};
use util::errors::{CargoError, CargoResultExt, Internal};
Ok(())
}
+pub fn mtime(path: &Path) -> CargoResult<FileTime> {
+ let meta = fs::metadata(path)
+ .chain_err(|| internal(format!("failed to stat `{}`", path.display())))?;
+ Ok(FileTime::from_last_modification_time(&meta))
+}
+
#[cfg(unix)]
pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> {
use std::os::unix::prelude::*;