Skip to content

Commit

Permalink
Snapshots are stored in the LMDB store not tar files
Browse files Browse the repository at this point in the history
This has a few advantages:
 1. It makes the Bazel remote execution API much easier to implement.
 2. We store each unique file by content exactly one time, rather than
    once per snapshot it belongs to.

It also allows us to delete a lot of code which handles awkward
specifics of tar files.
  • Loading branch information
illicitonion committed Nov 21, 2017
1 parent a4fbf46 commit 267a3d8
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 480 deletions.
44 changes: 0 additions & 44 deletions src/rust/engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/rust/engine/fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ lmdb = "0.7.2"
ordermap = "0.2.8"
protobuf = "1.4.1"
sha2 = "0.6.0"
tar = "0.4.13"
tempdir = "0.3.5"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/rust/engine/fs/fs_util/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ fn execute(top_match: clap::ArgMatches) -> Result<(), ExitError> {
paths,
)
})
.map(|snapshot| snapshot.digest.unwrap())
.map(|snapshot| snapshot.digest)
.wait()?;
Ok(println!("{} {}", digest.0, digest.1))
}
Expand Down
41 changes: 0 additions & 41 deletions src/rust/engine/fs/src/hash.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).

use digest::{Digest, FixedOutput};
use sha2::Sha256;

use std::error::Error;
use std::fmt;
use std::io::{self, Write};

use hex;

Expand Down Expand Up @@ -66,43 +62,6 @@ impl AsRef<[u8]> for Fingerprint {
}
}

///
/// A Write instance that fingerprints all data that passes through it.
///
pub struct WriterHasher<W: Write> {
hasher: Sha256,
inner: W,
}

impl<W: Write> WriterHasher<W> {
pub fn new(inner: W) -> WriterHasher<W> {
WriterHasher {
hasher: Sha256::default(),
inner: inner,
}
}

///
/// Returns the result of fingerprinting this stream, and Drops the stream.
///
pub fn finish(self) -> Fingerprint {
Fingerprint::from_bytes_unsafe(&self.hasher.fixed_result())
}
}

impl<W: Write> Write for WriterHasher<W> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
let written = self.inner.write(buf)?;
// Hash the bytes that were successfully written.
self.hasher.input(&buf[0..written]);
Ok(written)
}

fn flush(&mut self) -> io::Result<()> {
self.inner.flush()
}
}

#[cfg(test)]
mod fingerprint_tests {
use super::Fingerprint;
Expand Down
Loading

0 comments on commit 267a3d8

Please sign in to comment.