fix "Edit retention" fs capacity calculation

This was completely wrong: it overflowed on large filesystems and
double-counted the used bytes.

The new logic is still imperfect in that if there are a bunch of files in the
process of being deleted (moved from recording to reserved_sample_files but
not yet unlinked), they'll be taken out of the total capacity. Maybe it should
stat everything in the sample file directory instead of relying on the
recording table. It's definitely an improvement, though.
This commit is contained in:
Scott Lamb 2017-02-05 22:57:45 -08:00
parent da4e439b9c
commit b7957edb5a
1 changed files with 1 additions and 2 deletions

View File

@ -195,8 +195,7 @@ pub fn add_dialog(db: &Arc<db::Database>, dir: &Arc<dir::SampleFileDir>, siv: &m
}
}
let stat = dir.statfs().unwrap();
let fs_capacity = (stat.f_bsize * (stat.f_blocks - stat.f_bfree + stat.f_bavail)) as i64 -
total_used;
let fs_capacity = stat.f_bsize as i64 * stat.f_bavail as i64 + total_used;
Rc::new(RefCell::new(Model{
dir: dir.clone(),
db: db.clone(),