Enable client file listing for plugs

This commit is contained in:
Zef Hemel
2025-03-07 16:04:36 +01:00
parent d33db399c8
commit 7e706754f4
2 changed files with 8 additions and 9 deletions
+8 -1
View File
@@ -51,13 +51,16 @@ export class PlugSpacePrimitives implements SpacePrimitives {
async fetchFileList(): Promise<FileMeta[]> {
const allFiles: FileMeta[] = [];
const alreadySeenFiles = new Set<string>();
for (const { plug, name, operation, env } of this.hook.spaceFunctions) {
if (
operation === "listFiles" && (!this.env || (env && env === this.env))
operation === "listFiles" &&
(!this.env || !env || (env && env === this.env))
) {
try {
for (const pm of await plug.invoke(name, [])) {
allFiles.push(pm);
alreadySeenFiles.add(pm.name);
}
} catch (e: any) {
if (!e.message.includes("not available")) {
@@ -69,6 +72,10 @@ export class PlugSpacePrimitives implements SpacePrimitives {
}
const files = await this.wrapped.fetchFileList();
for (const pm of files) {
// We'll use the files coming from the wrapped space only as a fallback
if (alreadySeenFiles.has(pm.name)) {
continue;
}
allFiles.push(pm);
}
return allFiles;
-8
View File
@@ -3,8 +3,6 @@
This page contains configuration of SilverBullet and its plugs. Some of these changes will go into effect immediately, some require a page reload.
```space-config
# Initial page to load when launching SB, can contain template variables
indexPage: "[[SilverBullet]]"
libraries:
# The "Core" library is recommended for all users
- import: "[[!silverbullet.md/Library/Core/*]]"
@@ -68,12 +66,6 @@ smartQuotes:
left: "‘"
right: "’"
# Defines files to ignore in a format compatible with .gitignore
spaceIgnore: |
dist
largefolder
*.mp4
# Defines the maximum size of a file you can upload to the space (in MiB)
maximumDocumentSize: 10