Skip to content

Commit 03b8617

Browse files
Merge pull request #266 from vkryachko/no_empty_pkgs
Exclude packages with no files from the index.
2 parents 8c0532b + ce58f2a commit 03b8617

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/database.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,16 @@ impl Writer {
7171
files: FileTree,
7272
filter_prefix: &[u8],
7373
) -> io::Result<()> {
74+
let entries = files.to_list(filter_prefix);
75+
76+
// Don't add packages with no file entries to the database.
77+
if entries.is_empty() {
78+
return Ok(());
79+
}
7480
let writer = self.writer.as_mut().expect("not dropped yet");
7581
let mut encoder =
7682
frcode::Encoder::new(writer, b"p".to_vec(), serde_json::to_vec(&path).unwrap());
77-
for entry in files.to_list(filter_prefix) {
83+
for entry in entries {
7884
entry.encode(&mut encoder)?;
7985
}
8086
Ok(())

0 commit comments

Comments
 (0)