pub fn push(&mut self, sync: &mut IncompleteState) {
        // We start by clearing the old entry
        // This avoids any edge cases where we replace the cache with a new entry at the
        // same height (and path)
        if let Some(ref entry) = self.entry {
            match sync.state {
                DownloadState::Blank => {
                    // Keep what we have
                }
                _ => {
                    if sync.height >= entry.height {
                        self.entry = None;
                    }
                }
            };
        }

        match std::mem::replace(&mut sync.state, DownloadState::Blank) {
            DownloadState::Loading {
                manifest,
                fetch_chunks,
            } => {
                if self.entry.is_some() {
                    // The current cache is newer
                    delete_folder(&self.log, &sync.root);
                } else {
                    self.push_inner(sync, manifest, fetch_chunks);
                }
            }
            DownloadState::Complete(_) | DownloadState::Blank => {
                // Nothing to cache
                // Sanity check that the folder is gone (if completed, should have been moved to
                // a permanent checkpoint, if blank, should never have been created)
                if sync.root.exists() {
                    warn!(
                        self.log,
                        "Scratchpad exists for inactive state sync at {}. Deleting.",
                        sync.root.display()
                    );
                    delete_folder(&self.log, &sync.root);
                }
            }
        }
    }
/// Passes an `IncompleteState` `sync` to the cache, moving out any data
/// relevant to caching.
///
/// Only replaces the cache if `sync` has started, not finished, and
/// doesn't have an older height than what is currently in the cache.
///
/// This function takes ownership of any data on disk at `sync.root` and
/// resets the `state` to `Blank`. This function is intended to
/// be called in the `drop` function of `sync`, so changing the state is
/// safe.
Passes an `IncompleteState` `sync` to the cache, moving out any data
relevant to caching.

Only replaces the cache if `sync` has started, not finished, and
doesn't have an older height than what is currently in the cache.


Passes an ` IncompleteState ` ` sync ` to the cache moving out any data relevant to caching . Only replaces the cache if ` sync ` has started not finished and doesn ' t have an older height than what is currently in the cache .
pub fn push(&mut self, sync: &mut IncompleteState) {
        // We start by clearing the old entry
        // This avoids any edge cases where we replace the cache with a new entry at the
        // same height (and path)
        if let Some(ref entry) = self.entry {
            match sync.state {
                DownloadState::Blank => {
                    // Keep what we have
                }
                _ => {
                    if sync.height >= entry.height {
                        self.entry = None;
                    }
                }
            };
        }
        match std::mem::replace(&mut sync.state, DownloadState::Blank) {
            DownloadState::Loading {
                manifest,
                fetch_chunks,
            } => {
                if self.entry.is_some() {
                    // The current cache is newer
                    delete_folder(&self.log, &sync.root);
                } else {
                    self.push_inner(sync, manifest, fetch_chunks);
                }
            }
            DownloadState::Complete(_) | DownloadState::Blank => {
                // Nothing to cache
                // Sanity check that the folder is gone (if completed, should have been moved to
                // a permanent checkpoint, if blank, should never have been created)
                if sync.root.exists() {
                    warn!(
                        self.log,
                        "Scratchpad exists for inactive state sync at {}. Deleting.",
                        sync.root.display()
                    );
                    delete_folder(&self.log, &sync.root);
                }
            }
        }
    }
pub fn push ( & mut self , sync : & mut IncompleteState ) { // We start by clearing the old entry // This avoids any edge cases where we replace the cache with a new entry at the // same height (and path) if let Some ( ref entry ) = self . entry { match sync . state { DownloadState :: Blank => { // Keep what we have } _ => { if sync . height >= entry . height { self . entry = None ; } } } ; } match std :: mem :: replace ( & mut sync . state , DownloadState :: Blank ) { DownloadState :: Loading { manifest , fetch_chunks , } => { if self . entry . is_some ( ) { // The current cache is newer delete_folder ( & self . log , & sync . root ) ; } else { self . push_inner ( sync , manifest , fetch_chunks ) ; } } DownloadState :: Complete ( _ ) | DownloadState :: Blank => { // Nothing to cache // Sanity check that the folder is gone (if completed, should have been moved to // a permanent checkpoint, if blank, should never have been created) if sync . root . exists ( ) { warn ! ( self log " " sync root display ( ) ) ; delete_folder ( & self . log , & sync . root ) ; } } } }
Passes an `IncompleteState` `sync` to the cache, moving out any data
relevant to caching.
Passes an ` IncompleteState ` ` sync ` to the cache moving out any data relevant to caching .
&mut self
sync
&mut IncompleteState
&mut self
sync
&mut IncompleteState