[PR #3410] [MERGED] Handle library scan failure gracefully #3965

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

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/3410
Author: @mikiher
Created: 9/12/2024
Status: Merged
Merged: 9/13/2024
Merged by: @advplyr

Base: masterHead: library-scan-try-catch


📝 Commits (2)

  • 1099dbe Handle library scan failure gracefully
  • f8034e1 scanLibrary fail and cancel handling round 2

📊 Changes

2 files changed (+45 additions, -37 deletions)

View changed files

📝 server/scanner/LibraryScan.js (+4 -3)
📝 server/scanner/LibraryScanner.js (+41 -34)

📄 Description

This is in partial response to #3406

Library scan is a complex process and can fail in unexpected ways.
This tries wrap it up with a try-catch block, do the sensible things on error, save the scan log, and not crash the server.

There are a couple of questions I still have regarding the code:

  • In the following code:
        if (canceled && !libraryScan.totalResults) {
          task.setFinished('Scan canceled')
          TaskManager.taskFinished(task)
    
          const emitData = libraryScan.getScanEmitData
          emitData.results = null
          return
        }
    
    what is the last part trying to achieve? it seems it has no effect. Also, the premature return prevents some cleanups from happening.
  • In the following code:
      if (libraryScan.totalResults) {
        libraryScan.saveLog()
      }
    
    Why do we check library.Scan.totalResults? don't we want to save the scan log anyway?

🔄 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/3410 **Author:** [@mikiher](https://github.com/mikiher) **Created:** 9/12/2024 **Status:** ✅ Merged **Merged:** 9/13/2024 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `library-scan-try-catch` --- ### 📝 Commits (2) - [`1099dbe`](https://github.com/advplyr/audiobookshelf/commit/1099dbe642490195bc65b4439a670e515e45ae08) Handle library scan failure gracefully - [`f8034e1`](https://github.com/advplyr/audiobookshelf/commit/f8034e1b781a3732b7338b122a684914e630241b) scanLibrary fail and cancel handling round 2 ### 📊 Changes **2 files changed** (+45 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `server/scanner/LibraryScan.js` (+4 -3) 📝 `server/scanner/LibraryScanner.js` (+41 -34) </details> ### 📄 Description This is in partial response to #3406 Library scan is a complex process and can fail in unexpected ways. This tries wrap it up with a try-catch block, do the sensible things on error, save the scan log, and not crash the server. There are a couple of questions I still have regarding the code: - In the following code: ```js if (canceled && !libraryScan.totalResults) { task.setFinished('Scan canceled') TaskManager.taskFinished(task) const emitData = libraryScan.getScanEmitData emitData.results = null return } ``` what is the last part trying to achieve? it seems it has no effect. Also, the premature return prevents some cleanups from happening. - In the following code: ```js if (libraryScan.totalResults) { libraryScan.saveLog() } ``` Why do we check library.Scan.totalResults? don't we want to save the scan log anyway? --- <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:17:45 +02:00
adam closed this issue 2026-04-25 00:17:45 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3965