Skip to content

Commit c5f10b4

Browse files
author
Palmer Cox
committed
Update workcache to no longer use Sha1.
1 parent 2c30fce commit c5f10b4

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/libextra/workcache.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
#[allow(missing_doc)];
1212

13-
use digest::Digest;
1413
use json;
1514
use json::ToJson;
16-
use sha1::Sha1;
1715
use serialize::{Encoder, Encodable, Decoder, Decodable};
1816
use arc::{Arc,RWArc};
1917
use treemap::TreeMap;
@@ -23,7 +21,6 @@ use std::{os, str, task};
2321
use std::rt::io;
2422
use std::rt::io::Writer;
2523
use std::rt::io::Decorator;
26-
use std::rt::io::extensions::ReaderUtil;
2724
use std::rt::io::mem::MemWriter;
2825
use std::rt::io::file::FileInfo;
2926

@@ -276,19 +273,6 @@ fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
276273
Decodable::decode(&mut decoder)
277274
}
278275

279-
fn digest<T:Encodable<json::Encoder>>(t: &T) -> ~str {
280-
let mut sha = ~Sha1::new();
281-
(*sha).input_str(json_encode(t));
282-
(*sha).result_str()
283-
}
284-
285-
fn digest_file(path: &Path) -> ~str {
286-
let mut sha = ~Sha1::new();
287-
let s = path.open_reader(io::Open).read_to_end();
288-
(*sha).input(s);
289-
(*sha).result_str()
290-
}
291-
292276
impl Context {
293277

294278
pub fn new(db: RWArc<Database>,
@@ -497,6 +481,8 @@ impl<'self, T:Send +
497481
#[test]
498482
fn test() {
499483
use std::{os, run};
484+
use std::rt::io::ReaderUtil;
485+
use std::str::from_utf8_owned;
500486

501487
// Create a path to a new file 'filename' in the directory in which
502488
// this test is running.
@@ -524,8 +510,10 @@ fn test() {
524510
let subcx = cx.clone();
525511
let pth = pth.clone();
526512

513+
let file_content = from_utf8_owned(pth.open_reader(io::Open).read_to_end());
514+
527515
// FIXME (#9639): This needs to handle non-utf8 paths
528-
prep.declare_input("file", pth.as_str().unwrap(), digest_file(&pth));
516+
prep.declare_input("file", pth.as_str().unwrap(), file_content);
529517
do prep.exec |_exe| {
530518
let out = make_path(~"foo.o");
531519
// FIXME (#9639): This needs to handle non-utf8 paths

0 commit comments

Comments
 (0)