summary refs log tree commit diff
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-04-11 16:08:20 +0000
committeredef <edef@unfathomable.blue>2022-04-11 16:36:28 +0000
commitbed5094bf0a20069a13936d972058200eba48976 (patch)
treef9ee084c389945a034590ddb8bad572602a79287
parent62e3cac7747f6660d2b43ed5c21be8ab584dff5d (diff)
downloadunf-legacy-bed5094bf0a20069a13936d972058200eba48976.tar.zst
ripple/fossil: track file size
Change-Id: I424bd482d82471255f2ce2f17bb0b5c6eae3b77a
-rw-r--r--ripple/fossil/src/bin/extract.rs6
-rw-r--r--ripple/fossil/src/lib.rs10
-rw-r--r--ripple/fossil/src/store.proto1
3 files changed, 15 insertions, 2 deletions
diff --git a/ripple/fossil/src/bin/extract.rs b/ripple/fossil/src/bin/extract.rs
index e55c857..b21a063 100644
--- a/ripple/fossil/src/bin/extract.rs
+++ b/ripple/fossil/src/bin/extract.rs
@@ -38,7 +38,11 @@ fn extract(store: &fossil::Store, path: &Path, dir: &Directory) {
 				fs::create_dir(&path).unwrap();
 				extract(store, &path, &Directory::from_pb(pb));
 			}
-			fossil::Node::File(fossil::FileRef { ident, executable }) => {
+			fossil::Node::File(fossil::FileRef {
+				ident,
+				executable,
+				size: _,
+			}) => {
 				let mode = if executable { 0o755 } else { 0o644 };
 				let mut f = fs::OpenOptions::new()
 					.write(true)
diff --git a/ripple/fossil/src/lib.rs b/ripple/fossil/src/lib.rs
index 4d3f7b0..95dec02 100644
--- a/ripple/fossil/src/lib.rs
+++ b/ripple/fossil/src/lib.rs
@@ -56,6 +56,7 @@ impl Store {
 				Node::File(FileRef {
 					executable,
 					ident: self.write_blob(&blob),
+					size: blob.len().try_into().ok().expect("overflow"),
 				})
 			}
 			ty if ty.is_symlink() => {
@@ -142,6 +143,7 @@ pub struct DirectoryRef {
 pub struct FileRef {
 	pub ident: Digest,
 	pub executable: bool,
+	pub size: u32,
 }
 
 impl Node {
@@ -172,10 +174,15 @@ impl Directory {
 						r#ref: ident.as_bytes().to_vec(),
 					})
 				}
-				Node::File(FileRef { ident, executable }) => d.files.push(store::FileNode {
+				Node::File(FileRef {
+					ident,
+					executable,
+					size,
+				}) => d.files.push(store::FileNode {
 					name,
 					r#ref: ident.as_bytes().to_vec(),
 					executable,
+					size,
 				}),
 				Node::Link { target } => d.links.push(store::LinkNode { name, target }),
 			}
@@ -203,6 +210,7 @@ impl Directory {
 				Node::File(FileRef {
 					ident: digest_from_bytes(&child.r#ref),
 					executable: child.executable,
+					size: child.size,
 				}),
 			);
 		}
diff --git a/ripple/fossil/src/store.proto b/ripple/fossil/src/store.proto
index ff67d71..b2089db 100644
--- a/ripple/fossil/src/store.proto
+++ b/ripple/fossil/src/store.proto
@@ -21,6 +21,7 @@ message FileNode {
     string name = 1;
     bytes ref = 2;
     bool executable = 3;
+    uint32 size = 4;
 }
 
 message LinkNode {