Local dashboard shouldn't be showing system files (#10072)

close #10071

Changelog:
- update: `--filesystem-list` command to filter the hidden files
- update: project manager shim middleware to filter the hidden fiels
This commit is contained in:
Dmitry Bushev 2024-05-29 10:26:35 +01:00 committed by GitHub
parent 9baf555616
commit 79e20adcc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import * as http from 'node:http'
import * as os from 'node:os'
import * as path from 'node:path'
import * as isHiddenFile from 'is-hidden-file'
import * as tar from 'tar'
import * as yaml from 'yaml'
@ -221,6 +222,7 @@ export default function projectManagerShimMiddleware(
const entries: FileSystemEntry[] = []
for (const entryName of entryNames) {
const entryPath = path.join(directoryPath, entryName)
if (isHiddenFile.isHiddenFile(entryPath)) continue
const stat = await fs.stat(entryPath)
const attributes: Attributes = {
byteSize: stat.size,

View File

@ -36,6 +36,7 @@
"@stripe/stripe-js": "^2.1.10",
"esbuild-plugin-inline-image": "^0.0.9",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0"
"eslint-plugin-react-hooks": "^4.6.0",
"is-hidden-file": "^1.1.2"
}
}

View File

@ -10,6 +10,7 @@ import org.enso.projectmanager.infrastructure.repository.ProjectFileRepositoryFa
import org.enso.projectmanager.infrastructure.time.RealClock
import org.enso.projectmanager.protocol.FileSystemManagementApi.FileSystemList
import org.enso.projectmanager.service.filesystem.{
FileSystemEntry,
FileSystemService,
FileSystemServiceApi,
FileSystemServiceFailure
@ -24,6 +25,7 @@ final class FileSystemListCommand[
def run: F[FileSystemServiceFailure, FileSystemList.Result] =
service
.list(path)
.map(FileSystemListCommand.filterNotHidden)
.map(FileSystemList.Result)
}
@ -47,4 +49,15 @@ object FileSystemListCommand {
new FileSystemListCommand[F](service, path)
}
/** Filters the files system entries that are not hidden.
*
* @param entries the file system entries
* @return the filtered list of entries
*/
private def filterNotHidden(
entries: Seq[FileSystemEntry]
): Seq[FileSystemEntry] =
entries.filterNot(_.path.isHidden)
}

18
package-lock.json generated
View File

@ -602,7 +602,8 @@
"@stripe/stripe-js": "^2.1.10",
"esbuild-plugin-inline-image": "^0.0.9",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0"
"eslint-plugin-react-hooks": "^4.6.0",
"is-hidden-file": "^1.1.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.7.2",
@ -14345,6 +14346,21 @@
"node": ">=0.10.0"
}
},
"node_modules/is-hidden-file": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-hidden-file/-/is-hidden-file-1.1.2.tgz",
"integrity": "sha512-WS2Y+gFNWlK8IPAvcvsqa4rwf4kZUqGz3VTpHVhAu4Zvrbk+XPbve/RKacyyVNYxHQulubZshXXlzmfCR7G+WQ==",
"hasInstallScript": true,
"license": "MIT",
"os": [
"darwin",
"linux",
"win32"
],
"dependencies": {
"cross-spawn": "^7.0.3"
}
},
"node_modules/is-inside-container": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",