Skip to main content

pad_for

Function pad_for 

Source
pub(crate) fn pad_for(path: &Path, size: impl Fn(usize) -> u64) -> usize
Expand description

A file written again in place must change size. The sharing asks little of the sync app that carries the folder (docs/database.md, “What the sync app must do”): new files and files that grow, copied some day, in any order. Some sync apps tell a change by its size alone: eDrive (Murena’s, on /e/OS) downloads a file changed elsewhere only when its size differs from the copy it holds (its FileDiffUtils.getActionForFileDiff), and others compare size and time. So each rewrite is padded one step past the size of the file there now, up to PAD_LIMIT, then from the smallest again: a copy held elsewhere matches the newest only when a whole turn of rewrites (several hundred) went by unseen, and the next rewrite mends it. size(pad) is the file’s size with pad characters of padding.