This method goes over all the entries and rebuilds the indexes. WARNING: Please only use during upgrades to ensure enough intructions are available.
(&self)
| 50 | /// |
| 51 | /// WARNING: Please only use during upgrades to ensure enough intructions are available. |
| 52 | fn rebuild(&self) { |
| 53 | let mut entries = Vec::with_capacity(self.len()); |
| 54 | Self::with_db(|db| db.iter().for_each(|(_, v)| entries.push(v))); |
| 55 | |
| 56 | // First remove all the indexes. |
| 57 | self.clear_indexes(); |
| 58 | |
| 59 | // Then clear the repository because the key might have changed for the entries and |
| 60 | // we don't want to have dangling entries. |
| 61 | Self::with_db(|db| db.clear_new()); |
| 62 | |
| 63 | for value in entries { |
| 64 | // Then add the updated indexes. |
| 65 | self.add_entry_indexes(&value); |
| 66 | // Finally, update the entry in the database. |
| 67 | Self::with_db(|db| db.insert(value.key(), value)); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /// A repository is a generic interface for storing and retrieving data. |
nothing calls this directly
no test coverage detected