Skip to content

Commit

Permalink
Simplify RunFinder panel
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Jan 28, 2022
1 parent 245bab4 commit 607222f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/js/RunFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const populate = () => {
foundFolders = { number: 0, folders: {} }
store.commit('updateRunFolders', foundFolders)

store.state.svnProjects.forEach((root) => {
store.state.svnProjects.forEach(root => {
if (!root.hidden && root.slug !== 'gallery') drillIntoRootProject(root)
})
}
Expand All @@ -51,17 +51,18 @@ const drillIntoRootProject = function (root: FileSystemConfig) {

foundFolders.folders[root.name] = []

fetchFolders(root, fileSystem, '')
fetchFolders(root, fileSystem, '', 0)
}

const fetchFolders = async function (
root: FileSystemConfig,
fileSystem: HTTPFileSystem,
folder: string
folder: string,
deep: number
) {
try {
// skip some big folders we know we don't care about
if (root.skipList && root.skipList.filter((f) => folder.endsWith(f)).length) return
if (root.skipList && root.skipList.filter(f => folder.endsWith(f)).length) return

// skip .dot and __MACOSX folders
if (folder.endsWith('__MACOSX')) return
Expand All @@ -70,21 +71,25 @@ const fetchFolders = async function (
}

const { dirs } = await fileSystem.getDirectory(folder)

foundFolders.number++
foundFolders.folders[root.name].push({ root, path: folder })
foundFolders.folders[root.name].sort((a: any, b: any) => (a.path < b.path ? -1 : 1))
const realDirs = dirs.filter(d => !d.startsWith('.'))
for (const dir of realDirs) {
foundFolders.number++
foundFolders.folders[root.name].push({ root, path: folder + '/' + dir })
foundFolders.folders[root.name].sort((a: any, b: any) => (a.path < b.path ? -1 : 1))
}

// save the results
store.commit('updateRunFolders', foundFolders)
localStorage.setItem('RunFinder.foundFolders', JSON.stringify(foundFolders.folders))

for (const dir of dirs) {
// if (dir.startsWith('.')) continue
fetchFolders(root, fileSystem, `${folder}/${dir}`)
// // only recurse one deep, for now
if (deep < 1) {
for (const dir of realDirs) {
fetchFolders(root, fileSystem, `${folder}/${dir}`, deep + 1)
}
}
} catch (e) {
console.error(e)
console.warn(e)
}
}

Expand Down

0 comments on commit 607222f

Please sign in to comment.