PermissionError: [WinError 5] Access is denied when updating Metadata
I have been dealing with and or troubleshooting this for months and months. I have been using Calibre for many years now, but sometime in 2022 this issue started for me. I generally install the latest release of Calibre a few days after it is announced and I am currently running 6.16.
Here is an example error (this is just one of the three books for this author):
calibre, version 6.16.0
ERROR: Some failures: Failed to apply updated metadata for some books in your library. Click "Show details" to see details.
The Fugitive Pair - Henry Vogel
Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Documents\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 899, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 77, in call_func_with_lock
File "calibre\db\cache.py", line 1685, in set_metadata
File "calibre\db\cache.py", line 1506, in update_path
File "calibre\db\backend.py", line 1887, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Documents\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'
After this error, my library directory looks like this:
Directory of C:\Users\Richard\Documents\Calibre Library\Henry Vogel
04/25/2023 10:27 AM <DIR> .
04/25/2023 10:27 AM <DIR> ..
04/25/2023 10:27 AM <DIR> The Fugitive Heir (3951)
04/25/2023 10:27 AM <DIR> The Fugitive Heir_ Matt & Michelle (3951)
04/25/2023 10:26 AM <DIR> The Fugitive Pair (3952)
04/25/2023 10:26 AM <DIR> The Fugitive Pair_ Matt & Michelle (3952)
04/25/2023 10:27 AM <DIR> The Fugitive Snare (3953)
04/25/2023 10:27 AM <DIR> The Fugitive Snare_ Matt & Michelle (3953)
Three new directories were created and the files moved to them, but then it appears that when python tries to remove the old directories it fails.
I have confirmed absolutely that my directories are NOT read only and my user account running calibre has full access.
This sort of error can happen in two ways. If I am editing the meta data interactively one book at a time and using the download metadata feature, I sometimes get the error. However, if I just clear the error dialog and try to apply the changes again it works.
If I am bulk updating metadata for several books and download the metadata, when I finish reviewing and tweaking the downloaded metadata it errors out trying to save it.
This seems to be happening whenever python is being asked to move the book files between directories. If there is no directory involvement, no errors.
I previously had Google Drive syncing data to Google from the calibre library, but I have stopped that and have quite Drive but still get these errors.
If I run Library checks and have it fix/delete things, there's never an error.
My workaround has been to always edit books individually so I can retry without losing my changes.
|