fix: handle lost+found directory in plugin scanner

Signed-off-by: Beth Griggs <bethanyngriggs@gmail.com>
This commit is contained in:
Beth Griggs
2024-04-16 18:10:05 +01:00
parent 96ee5194b5
commit b611fd02a4
3 changed files with 28 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-dynamic-feature-service': patch
---
Updates the `scanRoot` method in the `PluginScanner` class to specifically ignore the `lost+found` directory, which is a system-generated directory used for file recovery on Unix-like systems. Skipping this directory avoids unnecessary errors.
@@ -636,6 +636,24 @@ Please add '${mockDir.resolve(
],
},
},
{
name: 'lost+found directory should be ignored',
fileSystem: {
backstageRoot: {
'dist-dynamic': {
'lost+found': {},
},
},
},
expectedPluginPackages: [],
expectedLogs: {
debugs: [
{
message: `skipping 'lost+found' system directory`,
},
],
},
},
])('$name', async (tc: TestCase): Promise<void> => {
const logger = new MockedLogger();
const backstageRoot = mockDir.resolve('backstageRoot');
@@ -136,6 +136,11 @@ export class PluginScanner {
withFileTypes: true,
})) {
const pluginDir = dirEnt;
if (pluginDir.name === 'lost+found') {
this.logger.debug(`skipping '${pluginDir.name}' system directory`);
continue;
}
const pluginHome = path.normalize(
path.resolve(dynamicPluginsLocation, pluginDir.name),
);