Bug 295178

Summary: poorly handled index.xml data corruption
Product: [Applications] kphotoalbum Reporter: Josef <lists>
Component: XML backendAssignee: KPhotoAlbum Bugs <kpabugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 4.1.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Josef 2012-03-01 21:24:22 UTC
Version:           4.1.1 (using KDE 4.7.4) 
OS:                Linux

My index.xml file got corrupted (perhaps when kphotoalbum closed due to power failure, but not sure). When I tried to start KPhotoAlbum with the corrupt file I get an error message saying 

Error on line 1 column 1 in file /home/josef/Pictures/index.xml: error occurred while parsing element

The only choice of action is the "OK" button. I had to manually find the hidden backup file ".#index.xml" and rename it. 

What I expected was that KPhotoAlbum would handle the situation by offering me an option to use the backup file. 

Reproducible: Always

Steps to Reproduce:
Start KPhotoAlbum with the corrupt XML file

Actual Results:  
KPhotoAlbum throws out an error message and quits.

Expected Results:  
KPhotoAlbum shows an error message and offers to restore the database from a backup.
Comment 1 Josef 2012-03-01 21:31:29 UTC
The corrupt file was too large to upload, so here is a link (~10 MB): http://josf.se/kphotoalbum-corrupt-file/index.xml
Comment 2 Miika Turkia 2012-03-03 18:45:56 UTC
Git commit 375ffdde59ee4a6e73fd25e2d5519c8a8eac9001 by Miika Turkia.
Committed on 03/03/2012 at 19:41.
Pushed by mturkia into branch 'master'.

Offering to recover from backup if index corrupted

If index.xml is corrupted we check if a backup exists. Then we ask the
user if he would like to use the backup.

M  +17   -8    Utilities/Util.cpp
M  +1    -1    Utilities/Util.h
M  +7    -2    XMLDB/FileReader.cpp

http://commits.kde.org/kphotoalbum/375ffdde59ee4a6e73fd25e2d5519c8a8eac9001