Provide fallback if resize fails (hopefully fixes gvfs errors)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@330 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 16 years ago
parent 0a2733a992
commit 8f5cf14b30
  1. 8
      src/Kdb3Database.cpp

@ -1455,13 +1455,17 @@ bool Kdb3Database::save(){
int size = EncryptedPartSize+DB_HEADER_SIZE; int size = EncryptedPartSize+DB_HEADER_SIZE;
if(!File->resize(size)){ if (!File->resize(size)){
if (File->size() > size) {
if (!File->remove() || !File->open(QIODevice::ReadWrite)) {
delete [] buffer; delete [] buffer;
error=decodeFileError(File->error()); error=decodeFileError(File->error());
return false; return false;
} }
}
}
File->seek(0); File->seek(0);
if(File->write(buffer,size)!=size){ if (File->write(buffer,size)!=size){
delete [] buffer; delete [] buffer;
error=decodeFileError(File->error()); error=decodeFileError(File->error());
return false; return false;