audiobookshelf
audiobookshelf copied to clipboard
[Bug]: M4B Conversion via API does not check if a conversion is already in progress - Server Crash
What happened?
If you use the API to initialize an M4B conversion of a library item, it does not check if the current item is already being encoded - if you send the request twice, ABS initializes ffmpeg twice, trying to access the same files (you can watch this very easily because both threads try to update the percentage done on the ABS interface), eventually crashing the server when the second thread tries to access the files.txt file locked by the first process.
This leads to a complete server crash.
What did you expect to happen?
The API should be thread aware and deny a request if an encoding is already in progress / just let the process continue instead of spawning a second encoder.
Steps to reproduce the issue
- Start encoding a Library item via the API
- Send the same command a second time while the encoding is ongoing
Audiobookshelf version
v2.12.3
How are you running audiobookshelf?
Windows Tray App
What OS is your Audiobookshelf server hosted from?
Windows
If the issue is being seen in the UI, what browsers are you seeing the problem on?
None
Logs
{"timestamp":"2024-08-21 14:13:25.661","source":" at process.<anonymous> (C:\\snapshot\\audiobookshelf\\server\\Server.js)","message":"[Server] Unhandled rejection: Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt', promise: Promise {\n <rejected> [Error: EBUSY: resource busy or locked, unlink 'C:\\Audiobookshelf\\Data\\metadata\\cache\\items\\402d7afe-6672-4524-9516-d70bd423c6bb\\files.txt'] {\n errno: -4082,\n code: 'EBUSY',\n syscall: 'unlink',\n path: 'C:\\\\Audiobookshelf\\\\Data\\\\metadata\\\\cache\\\\items\\\\402d7afe-6672-4524-9516-d70bd423c6bb\\\\files.txt'\n }\n}","levelName":"FATAL","level":5}
Additional Notes
No response