From c5f10b47f33f8765aa538c6fca936745e8cf8519 Mon Sep 17 00:00:00 2001 From: Palmer Cox Date: Tue, 22 Oct 2013 23:16:12 -0400 Subject: [PATCH] Update workcache to no longer use Sha1. --- src/libextra/workcache.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs index 30efecde37f9..bdc8b95ad411 100644 --- a/src/libextra/workcache.rs +++ b/src/libextra/workcache.rs @@ -10,10 +10,8 @@ #[allow(missing_doc)]; -use digest::Digest; use json; use json::ToJson; -use sha1::Sha1; use serialize::{Encoder, Encodable, Decoder, Decodable}; use arc::{Arc,RWArc}; use treemap::TreeMap; @@ -23,7 +21,6 @@ use std::{os, str, task}; use std::rt::io; use std::rt::io::Writer; use std::rt::io::Decorator; -use std::rt::io::extensions::ReaderUtil; use std::rt::io::mem::MemWriter; use std::rt::io::file::FileInfo; @@ -276,19 +273,6 @@ fn json_decode>(s: &str) -> T { Decodable::decode(&mut decoder) } -fn digest>(t: &T) -> ~str { - let mut sha = ~Sha1::new(); - (*sha).input_str(json_encode(t)); - (*sha).result_str() -} - -fn digest_file(path: &Path) -> ~str { - let mut sha = ~Sha1::new(); - let s = path.open_reader(io::Open).read_to_end(); - (*sha).input(s); - (*sha).result_str() -} - impl Context { pub fn new(db: RWArc, @@ -497,6 +481,8 @@ impl<'self, T:Send + #[test] fn test() { use std::{os, run}; + use std::rt::io::ReaderUtil; + use std::str::from_utf8_owned; // Create a path to a new file 'filename' in the directory in which // this test is running. @@ -524,8 +510,10 @@ fn test() { let subcx = cx.clone(); let pth = pth.clone(); + let file_content = from_utf8_owned(pth.open_reader(io::Open).read_to_end()); + // FIXME (#9639): This needs to handle non-utf8 paths - prep.declare_input("file", pth.as_str().unwrap(), digest_file(&pth)); + prep.declare_input("file", pth.as_str().unwrap(), file_content); do prep.exec |_exe| { let out = make_path(~"foo.o"); // FIXME (#9639): This needs to handle non-utf8 paths