Unable to Open Calibre after Moving Library

Bug #1238255 reported by George
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Invalid
Undecided
Unassigned

Bug Description

I have found a problem with the Calibre program. I suppose that technically it is not a bug but there is a trap that can result in someone never being able to use Calibre again on the PC. I decided to move the Calibre library. I am now aware of the option to move a library within the program. At the time however, I moved the folder with a file manager and somehow also corrupted the "metadata.db" and "metadata_db_prefs_backup.json" files. I closed Calibre and when I reopened it, I was presented an option to recover the library. The recovery failed and Calibre closed. I tried to open it several times unsuccessfully. I even tried uninstalling the program and used a registry cleaner to remove remnants the program. After I reinstalled the program, the problem remained and it continued to unsuccessfully recover the library and would close without opening the program. Evidently there was something left in the registry about the library that was never deleted when I uninstalled the program. I was beginning to think I would never be able to use Calibre again. I finally decided to use a backup I had of the library and copied it back to the original location before moving it. The restore function finally did work this time and Calibre opened. At this point, I was able to use the option within the program to move the library where I wanted it. After successfully moving it, I promptly made a backup copy.

If the restore function fails, please change the program to provide an option to open the program with no library, possibly in a way similar to how the program is opened for the first time. If I did not have a backup copy of my library, I would never have been able to use Calibre again. I have used other programs that use a library and have on occasion lost the connection to the library. These programs usually just open up with no content and then you can then reestablish the connection to the library through a file menu option. Having Calibre function this way would be preferable.

Revision history for this message
Eli Schwartz (eschwartz) wrote :

Calibre wouldn't have been forever broken. In fact, it didn't have any problems at all other than it was trying to read a mangled database and couldn't. There was nothing in the registry to clean (or at least, no more than the usual Windows crap.) Worst case scenario, rename the library and calibre won't find it. Or delete it. But you can easily fix it as follows:

Rename the broken library in the file explorer. Open calibre and create a new library. Close calibre.

***********************************************************************
*** All device settings, conversion choices, tweaks, general stuff that is ***
*** cross-library is not stored in the db and stayed safe anyway. ***
***********************************************************************

Copy the file metadata_db_prefs_backup.json from the old library folder to the new one -- this contains all the plugboards, custom columns, saved searches, virtual libraries, etc. and is backed up when calibre quits-- basically, anything that IS stored per-library. Even the data for the Overdrive link plugin, which unlike most plugins stores stuff in the database.

Open calibre, and go to Libraries ==> Library Maintenance ==> Restore Database.

Now import all your books from the renamed folder. Use Add Books ==> Add books from directories,... (One book per directory, assumes each file is the same book in a different format). Treating a calibre library as if it were a saved-to-disk library has worked for me several times, (adding from a portableapps windows library to a linux library if I forget to save,) and it takes into account all metadata changes saved into the metadata.opf backups.

All your info is now back -- the settings saved in the config folder, the per-library settings in metadata_db_prefs_backup.json, and the actual ebook files, which aren't edited by the database, together with the latest metadata changes you made. It will even add the metadata for you custom columns.

Revision history for this message
George (johnhoward1234890) wrote :

I think your interests would be better served that you open a blank database if the recovery fails for dummies like me.

Revision history for this message
Gorgo (jjloperhet) wrote :

After deletion of few books with freecommmander/windows, I can't re start Calibre (64 bits/windows) Messages number are presented in a libre office file attached.
When I start Calibre message 1 appeared
If I select OK, Calibre tries to restore the database : step 1 & 2 OK but step 3 message 2 appears
Then if I try to select a new, empty directory, Calibre closes
If I try to select a new directory where metadata_db_prefs_backup.json has been copied, i get the message 1 et so on...
What can I do???????

Revision history for this message
Kovid Goyal (kovid) wrote :

Run the restore from the command prompt, whatever is blocking calibre is less likely to interfere with the command line restore. Like this

calibredb restore_database -r

Revision history for this message
Gorgo (jjloperhet) wrote :

I tried and the result is again:
Restoring database failed with error:
Traceback (most recent call last)
  File "site-package\calibre\db\restore.py", line 125, in run
  File "site-package\calibre\db\restore.py", line 276 , in replace_db
  File "shutil.py", line 86, in copyfile
IOError: [Errno 13] Permission denied: u'D: \\MY NAME\\Mes Documents\\Bibliot\xe8que calibre\\metadata_pre_restore.db'

I get the same result in "adminitrator mode".

Nota : the file metadata.db is neither read only nor hidden

Revision history for this message
Kovid Goyal (kovid) wrote :

Weel you have something on your computer than is preventing access to the file, if it is not file permissions, then it is an overzealous anti-virus or file sync program. And the file in question is

metadata_pre_restore.db not metadata.db

Revision history for this message
Charles Haley (cbhaley) wrote :

I have a very vague memory of some problems when accented characters are used in the library path. What happens if you change the è in bibliothèque to an unaccented e?

Apologies if my memory is faulty.

Revision history for this message
Gorgo (jjloperhet) wrote :

Thanks a lot, it was a new functionnality of my anti-virus which denied acces to softwares
I forbade instead of authorizing acces to directories for these software, whose calibre and calibredb.
Calibre is OK :-)
This forum is effective

Eli Schwartz (eschwartz)
Changed in calibre:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.