[PR #1547] [MERGED] Nginx-UI disk I/O #4420

Closed
opened 2026-02-28 12:00:19 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/0xJacky/nginx-ui/pull/1547
Author: @0xJacky
Created: 2/6/2026
Status: Merged
Merged: 2/7/2026
Merged by: @0xJacky

Base: devHead: cursor/nginx-ui-disk-i-o-3d99


📝 Commits (9)

  • 4cae78c fix: prevent disk I/O overload from static files in nginx config directory
  • 1af40fb Fix path matching bugs in shouldSkipPath and shouldWatchDirectory
  • c391f20 fix: use relative paths for static directory pattern matching to avoid ancestor match
  • ded394f fix: use filepath.Separator for cross-platform path matching in static directory checks
  • d18cebf fix: reorder static dir checks before config dir checks to prevent I/O overload
  • 35e2872 fix: remove redundant config dir check and add path-separator boundaries
  • fc27e51 perf: move constant data structures to package level to avoid allocations
  • e1c6fce fix: remove redundant HasPrefix check in isConfigFilePath
  • deb0ad7 fix: remove dead HasPrefix branch in config dir pattern matching

📊 Changes

1 file changed (+245 additions, -24 deletions)

View changed files

📝 internal/cache/index.go (+245 -24)

📄 Description

Filter file watcher and scanner to ignore static asset directories and non-config files to prevent disk I/O overload.

When static asset folders (like /etc/nginx/html/dist) were placed in the nginx config path, the file monitoring system (fsnotify) would generate a huge number of events for every file change (e.g., during zip extraction). Each event triggered a file scan, leading to massive I/O operations and server unresponsiveness. This PR introduces granular filtering for both directories and individual files to ensure only relevant Nginx configuration files are processed.


Open in Cursor Open in Web


Note

Medium Risk
Changes core file-watching and scan inclusion logic; misclassification could cause some valid configs to be missed or delay index updates, though impact is limited to scanning behavior.

Overview
Reduces disk I/O from the nginx config scanner/watcher by filtering out static-asset directories and non-config files so mass file operations (e.g., extracting a zip) don’t trigger scans.

Expands excluded paths to include common web roots (e.g., html, static, assets, public, webroot), tightens shouldSkipPath to avoid prefix false positives, and introduces shouldWatchDirectory + isConfigFilePath heuristics (directory-name patterns, nginx config dirs, known config filenames, and a denylist of non-config extensions). These filters are applied to directory walking, dynamic watcher additions, file-event handling (including removals), and recursive scanning to skip irrelevant paths early.

Written by Cursor Bugbot for commit deb0ad7590. This will update automatically on new commits. Configure here.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/0xJacky/nginx-ui/pull/1547 **Author:** [@0xJacky](https://github.com/0xJacky) **Created:** 2/6/2026 **Status:** ✅ Merged **Merged:** 2/7/2026 **Merged by:** [@0xJacky](https://github.com/0xJacky) **Base:** `dev` ← **Head:** `cursor/nginx-ui-disk-i-o-3d99` --- ### 📝 Commits (9) - [`4cae78c`](https://github.com/0xJacky/nginx-ui/commit/4cae78c790663554353752026790c6d05d34497e) fix: prevent disk I/O overload from static files in nginx config directory - [`1af40fb`](https://github.com/0xJacky/nginx-ui/commit/1af40fbdd4605e976d64a1ba86df8ea8540d383a) Fix path matching bugs in shouldSkipPath and shouldWatchDirectory - [`c391f20`](https://github.com/0xJacky/nginx-ui/commit/c391f20a8ff870cc9161dd16c67b091ee239fcc1) fix: use relative paths for static directory pattern matching to avoid ancestor match - [`ded394f`](https://github.com/0xJacky/nginx-ui/commit/ded394f4bcb597e4c1510f1f67769dd6c9756a1b) fix: use filepath.Separator for cross-platform path matching in static directory checks - [`d18cebf`](https://github.com/0xJacky/nginx-ui/commit/d18cebf2e64ac61ab7d20700144d19cf98ce8c1d) fix: reorder static dir checks before config dir checks to prevent I/O overload - [`35e2872`](https://github.com/0xJacky/nginx-ui/commit/35e287289684ce5a5a186191f66573e95467876e) fix: remove redundant config dir check and add path-separator boundaries - [`fc27e51`](https://github.com/0xJacky/nginx-ui/commit/fc27e51cb51665e5d1310f3f80957613bcfcfb97) perf: move constant data structures to package level to avoid allocations - [`e1c6fce`](https://github.com/0xJacky/nginx-ui/commit/e1c6fcea4d380e6e15e5012300fdec0e3df105a0) fix: remove redundant HasPrefix check in isConfigFilePath - [`deb0ad7`](https://github.com/0xJacky/nginx-ui/commit/deb0ad7590ada9d9046d0a1eb8f91b76da1bdcdf) fix: remove dead HasPrefix branch in config dir pattern matching ### 📊 Changes **1 file changed** (+245 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `internal/cache/index.go` (+245 -24) </details> ### 📄 Description Filter file watcher and scanner to ignore static asset directories and non-config files to prevent disk I/O overload. When static asset folders (like `/etc/nginx/html/dist`) were placed in the nginx config path, the file monitoring system (fsnotify) would generate a huge number of events for every file change (e.g., during zip extraction). Each event triggered a file scan, leading to massive I/O operations and server unresponsiveness. This PR introduces granular filtering for both directories and individual files to ensure only relevant Nginx configuration files are processed. --- <p><a href="https://cursor.com/background-agent?bcId=bc-f3591099-69e7-46ca-ac63-12228913e59b"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-f3591099-69e7-46ca-ac63-12228913e59b"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a></p> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core file-watching and scan inclusion logic; misclassification could cause some valid configs to be missed or delay index updates, though impact is limited to scanning behavior. > > **Overview** > Reduces disk I/O from the nginx config scanner/watcher by **filtering out static-asset directories and non-config files** so mass file operations (e.g., extracting a zip) don’t trigger scans. > > Expands excluded paths to include common web roots (e.g., `html`, `static`, `assets`, `public`, `webroot`), tightens `shouldSkipPath` to avoid prefix false positives, and introduces `shouldWatchDirectory` + `isConfigFilePath` heuristics (directory-name patterns, nginx config dirs, known config filenames, and a denylist of non-config extensions). These filters are applied to directory walking, dynamic watcher additions, file-event handling (including removals), and recursive scanning to skip irrelevant paths early. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit deb0ad7590ada9d9046d0a1eb8f91b76da1bdcdf. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 12:00:19 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#4420
No description provided.