Skip to content

Commit 937b35b

Browse files
authored
Merge pull request #4276 from illume/watch-loop
app: backend: Fix for plugin watch doing a loop on mac app
2 parents 77399a4 + 666294b commit 937b35b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app/electron/plugin-management.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,15 @@ export function getPluginBinDirectories(pluginsDir: string): string[] {
10761076
for (const file of files) {
10771077
const filePath = path.join(binDir, file);
10781078
// Skip directories
1079-
if (fs.statSync(filePath).isDirectory()) {
1079+
const stat = fs.statSync(filePath);
1080+
if (stat.isDirectory()) {
10801081
continue;
10811082
}
1082-
fs.chmodSync(filePath, 0o755); // rwx r-x r-x
1083+
const currentMode = stat.mode & 0o777;
1084+
if (currentMode !== 0o755) {
1085+
console.log(`Setting executable permissions for ${filePath}`);
1086+
fs.chmodSync(filePath, 0o755); // rwx r-x r-x
1087+
}
10831088
}
10841089
} catch (err) {
10851090
console.error(`Error setting executable permissions in ${binDir}:`, err);

backend/pkg/plugins/plugins.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,13 @@ func canSendRefresh(c cache.Cache[interface{}]) bool {
377377
func HandlePluginEvents(staticPluginDir, userPluginDir, pluginDir string,
378378
notify <-chan string, cache cache.Cache[interface{}],
379379
) {
380-
for range notify {
380+
for event := range notify {
381+
// Skip CHMOD events to avoid looping on electron when user-plugins folder is watched
382+
// these events are not relevant to see if plugins have changed.
383+
if strings.HasSuffix(event, "CHMOD") {
384+
continue
385+
}
386+
381387
// Set the refresh signal only if we cannot send it. We prevent it here
382388
// because we only want to send refresh signals that *happen after* we are
383389
// allowed to send them.

0 commit comments

Comments
 (0)