[PR #699] [MERGED] Update some instances of mkdir to ensureDir (#698) #3396

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

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/699
Author: @jmt-gh
Created: 6/6/2022
Status: Merged
Merged: 6/8/2022
Merged by: @advplyr

Base: masterHead: 698_metadata_downloads_not_created


📝 Commits (5)

  • 35f29ca Use ensureDir instead of mkdir to fix 698
  • c606a41 update Cache folder creation to leverage ensureDirs
  • 853513b update approach for ensuring download directory always exists
  • 8d03943 remove extra debug log
  • f5aae25 remove random character

📊 Changes

2 files changed (+20 additions, -1 deletions)

View changed files

📝 server/Server.js (+2 -1)
📝 server/managers/AbMergeManager.js (+18 -0)

📄 Description

This PR resolves #698.

mkdir was being used instead of ensureDirs, or mkdirs or mkdirp. AbMergeManager doesn't precreate the Downloads folder structure it needes -- updating it to use ensureDirs handles creating the entire path needed when a merge attempt gets kicked off.

I also did a driveby and updated mkdir for CacheManager to also leverage ensureDirs. CacheManager was a bit safer already, but if the first mkdir had failed for any reason, the resulting ones would have failed as well, resulting in a server crash at startup. While changing these to ensureDir doesn't necessarily guarantee whatever might cause the first creation to fail won't happen again on these subsequent attempts, it will at least mean that we'll try and recreate the entire structure needed a few times.


🔄 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/699 **Author:** [@jmt-gh](https://github.com/jmt-gh) **Created:** 6/6/2022 **Status:** ✅ Merged **Merged:** 6/8/2022 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `698_metadata_downloads_not_created` --- ### 📝 Commits (5) - [`35f29ca`](https://github.com/advplyr/audiobookshelf/commit/35f29ca22b5fc84a49b4d8cc6182bc7db6d824dc) Use ensureDir instead of mkdir to fix 698 - [`c606a41`](https://github.com/advplyr/audiobookshelf/commit/c606a41314019de9b8a13dee1d72881eeb07121a) update Cache folder creation to leverage ensureDirs - [`853513b`](https://github.com/advplyr/audiobookshelf/commit/853513b92685969d83da769db7c649b69ea9a27b) update approach for ensuring download directory always exists - [`8d03943`](https://github.com/advplyr/audiobookshelf/commit/8d03943acbcdb34de5a98d0e9127cc59dfff6bc1) remove extra debug log - [`f5aae25`](https://github.com/advplyr/audiobookshelf/commit/f5aae25cc8bf2f6abde29876c9e50aef84aceda0) remove random character ### 📊 Changes **2 files changed** (+20 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/Server.js` (+2 -1) 📝 `server/managers/AbMergeManager.js` (+18 -0) </details> ### 📄 Description This PR resolves #698. mkdir was being used instead of [ensureDirs, or mkdirs or mkdirp](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir.md). AbMergeManager doesn't precreate the Downloads folder structure it needes -- updating it to use ensureDirs handles creating the entire path needed when a merge attempt gets kicked off. I also did a driveby and updated mkdir for CacheManager to also leverage ensureDirs. CacheManager was a bit safer already, but if the first mkdir had failed for any reason, the resulting ones would have failed as well, resulting in a server crash at startup. While changing these to ensureDir doesn't necessarily guarantee whatever might cause the first creation to fail won't happen again on these subsequent attempts, it will at least mean that we'll try and recreate the entire structure needed a few times. --- <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:15:29 +02:00
adam closed this issue 2026-04-25 00:15:29 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3396