MCPcopy Create free account
hub / github.com/endbasic/endbasic / fixup_names

Method fixup_names

web/src/store.rs:151–176  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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<()> {

Callers 2

from_windowMethod · 0.80

Calls 3

parseFunction · 0.85
canonicalMethod · 0.80
renameMethod · 0.80

Tested by 1