Upgrades the drive to support case insensitive behavior. This scans for all existing files in the drive and, for any that have names that are not in canonical form (all uppercase), renames them to canonical form.
(&mut self)
| 149 | /// This scans for all existing files in the drive and, for any that have names that are not in |
| 150 | /// canonical form (all uppercase), renames them to canonical form. |
| 151 | fn fixup_names(&mut self) -> io::Result<()> { |
| 152 | let n = match self.storage.length() { |
| 153 | Ok(n) => n, |
| 154 | Err(e) => return Err(io::Error::other(format!("{:?}", e))), |
| 155 | }; |
| 156 | for i in 0..n { |
| 157 | let key = match self.storage.key(i) { |
| 158 | Ok(Some(key)) => key, |
| 159 | Ok(None) => return Err(io::Error::other("Entry vanished")), |
| 160 | Err(e) => { |
| 161 | return Err(io::Error::other(format!( |
| 162 | "Failed to fetch local storage entry with index {}: {:?}", |
| 163 | i, e |
| 164 | ))); |
| 165 | } |
| 166 | }; |
| 167 | |
| 168 | if let Some(key) = Key::parse(&key) { |
| 169 | let canonical = key.canonical(); |
| 170 | if key != canonical { |
| 171 | self.rename(&key, &canonical)?; |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | Ok(()) |
| 176 | } |
| 177 | |
| 178 | /// Renames a file stored with an `old` key to a `new` key. |
| 179 | fn rename(&self, old: &Key, new: &Key) -> io::Result<()> { |