[PR #4031] [MERGED] Refactor ignore file logic #4150

Closed
opened 2026-04-25 00:18:33 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4031
Author: @nichwall
Created: 2/22/2025
Status: Merged
Merged: 2/23/2025
Merged by: @advplyr

Base: masterHead: temp_file_ignore_refactor


📝 Commits (2)

  • 13c20e0 Add: generic function to ignor files
  • 20f8124 Add fileUtils recurseFiles and shouldIgnoreFile tests

📊 Changes

3 files changed (+171 additions, -20 deletions)

View changed files

📝 server/Watcher.js (+5 -10)
📝 server/utils/fileUtils.js (+39 -10)
test/server/utils/fileUtils.test.js (+127 -0)

📄 Description

Brief summary

This PR refactors the "file ignore" for the scanner and watcher.

Which issue is fixed?

Fixes https://github.com/advplyr/audiobookshelf/issues/2399 and https://github.com/advplyr/audiobookshelf/issues/4029
This helps with https://github.com/advplyr/audiobookshelf/issues/1641, but is not user-configurable like that request is.

In-depth Description

This adds additional file extensions to the ignore list in the scanner and watcher, and creates a new utility function to ensure both ignore lists stay in sync.

Ignored file extensions are:

  • .part
  • .tmp
  • .temp
  • .crdownload
  • .download
  • .bak
  • .old
  • .tempfile
  • .tempfile~

This function also checks for dotfiles and dotpaths to simplify the calling functions.

This function adds a framework to ignore the file or path whenever a specific string appears anywhere in the relative path. This is to help address vendor-specific paths like @eaDir from Synology.

This PR does not do anything to the database, it only affects the scanner and watcher.

How have you tested this?

Created a new library with each of the ignored extensions and using the ignored extension as the "filename" and a valid extension such as crdownload.mp3 to ensure the filter applies correctly. I also created an @eaDir with valid media files to ensure they were ignored correctly.

I then enabled the watcher and performed the same test in a new directory.

Screenshots

N/A


🔄 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/advplyr/audiobookshelf/pull/4031 **Author:** [@nichwall](https://github.com/nichwall) **Created:** 2/22/2025 **Status:** ✅ Merged **Merged:** 2/23/2025 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `temp_file_ignore_refactor` --- ### 📝 Commits (2) - [`13c20e0`](https://github.com/advplyr/audiobookshelf/commit/13c20e0cddc22d1431ce9f4865380a3a17b8f18c) Add: generic function to ignor files - [`20f8124`](https://github.com/advplyr/audiobookshelf/commit/20f812403f50db712f2bcf5f350baff523153fd6) Add fileUtils recurseFiles and shouldIgnoreFile tests ### 📊 Changes **3 files changed** (+171 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `server/Watcher.js` (+5 -10) 📝 `server/utils/fileUtils.js` (+39 -10) ➕ `test/server/utils/fileUtils.test.js` (+127 -0) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary This PR refactors the "file ignore" for the scanner and watcher. ## Which issue is fixed? Fixes https://github.com/advplyr/audiobookshelf/issues/2399 and https://github.com/advplyr/audiobookshelf/issues/4029 This helps with https://github.com/advplyr/audiobookshelf/issues/1641, but is not user-configurable like that request is. ## In-depth Description This adds additional file extensions to the ignore list in the scanner and watcher, and creates a new utility function to ensure both ignore lists stay in sync. Ignored file extensions are: - `.part` - `.tmp` - `.temp` - `.crdownload` - `.download` - `.bak` - `.old` - `.tempfile` - `.tempfile~` This function also checks for dotfiles and dotpaths to simplify the calling functions. This function adds a framework to ignore the file or path whenever a specific string appears anywhere in the relative path. This is to help address vendor-specific paths like `@eaDir` from Synology. This PR does *not* do anything to the database, it only affects the scanner and watcher. ## How have you tested this? Created a new library with each of the ignored extensions and using the ignored extension as the "filename" and a valid extension such as `crdownload.mp3` to ensure the filter applies correctly. I also created an `@eaDir` with valid media files to ensure they were ignored correctly. I then enabled the watcher and performed the same test in a new directory. ## Screenshots N/A --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:18:33 +02:00
adam closed this issue 2026-04-25 00:18:33 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4150