[bt-devel] CSwordBackend::deleteOrphanedIndices()

Martin Gruner mg.pub at gmx.net
Thu Aug 5 03:40:11 MST 2010


Hi Olaf,

I don't see a problem in the original function deleteOrphanedIndices.

It first goes to the directory
CSwordModuleInfo::getGlobalBaseIndexLocation(), which is where all
module index directories are supposed to be. That would be
~/.bibletime/indices on Linux. Then it loops through all directories,
each representing one module. If there is a corresponding module
installed, but hasIndex() is false, the module index will be removed
(wrong version etc.). If no module is found, the index directory will be
removed too. So the code is sane imo.

Your patch loops through all module subdirectories, and checks if one
bibletime-index.conf is present, and then calls the original method. I
don't see an added value there, because you are trying to work around a
problem in the code with more code. Instead we should identify the real
problem and fix it (if any).

If something strange was deleted on your system, we'd have to check
CSwordModuleInfo::getGlobalBaseIndexLocation() instead (what if that
directory doesn't yet exist?). Maybe you can try to reproduce exactly
what went wrong here, so that we can add some checks.

Regards, mg

Am 29.07.10 15:13, schrieb Olaf Radicke:
> On Wed, Jul 28, 2010 at 10:42:51AM -0700, Gary Holmlund wrote:
>   
>> On 7/28/2010 8:15 AM, Olaf Radicke wrote:
>>     
>>> On Wed, Jul 28, 2010 at 06:49:22AM -0700, Gary Holmlund wrote:
>>>       
>>>> On 07/28/2010 05:03 AM, Olaf Radicke wrote:
>>>>         
>>>>> On Wed, Jul 28, 2010 at 11:38:55AM +0200, Olaf Radicke wrote:
>>>>>           
>>>>>> On Mon, Jul 26, 2010 at 12:49:12PM +0200, Olaf Radicke wrote:
>>>>>>             
>>>>>>> At coding on alter-gui, the function void CSwordBackend::deleteOrphanedIndices()
>>>>>>> has delete my complete directory and all subdirectory. Wickedly funny. So
>>>>>>> i think, the function missing checks?
>>>>>>>               
>>>>>> I can't find which class generated the indices and/or a documantion from
>>>>>> characteristics of indices-files or indices-directorys. So i can't pach this
>>>>>> problem.
>>>>>>             
>>>>> In function CSwordModuleInfo::buildIndex() i have fond this in line 399:
>>>>>
>>>>> QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
>>>>>
>>>>> ...So is it a good idea check direktory of a file with name 'bibletime-index.conf'?
>>>>>
>>>>> Olaf
>>>>>           
>>>> The first parameter for this QSettings line is supposed to be a file
>>>> name, so I don't understand what you mean about checking a
>>>> directory. The line looks good to me.
>>>>         
>>> No, the prolem is the function CSwordBackend::deleteOrphanedIndices(). To date
>>> the function delete the complete directory and all subdirectorys, without
>>> any checks. So my question is:
>>>
>>> Is it a good idea, checking direktory of a file with name 'bibletime-index.conf',
>>> _before_ the function CSwordBackend::deleteOrphanedIndices() is starting the
>>> deletion complete directory?
>>>
>>> Olaf Radicke
>>>       
>> Olaf,
>>
>> I don't know the backend code well enough to answer this question.
>> Does anyone else?
>>     
> Okay, here is my suggestion:
>
> void CSwordBackend::safeDeleteOrphanedIndices()
> {
>     QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
>     bool isCorrectDir = false;
>
>     QDirIterator it(dir);
>     while (it.hasNext())
>     {
>         QString aDir = it.next();
>         aDir = aDir + QDir::separator() + "bibletime-index.conf";
>         QFile  file( aDir );
>         qDebug() << "[or20100729140101] check fiele name: " << file.fileName();
>         if( file.exists() )
>         {
>             isCorrectDir = true;
>             qDebug() << "[or20100729125902] isCorrectDir = true ";
>         }
>     }
>   
>     if(!isCorrectDir)
>     {
>         qDebug() << "[or20100729125903] isCorrectDir = false ";
>         QString errorInfo = "is not a indices directory.";
>         throw errorInfo.toStdString();
>     }
>     else
>     {
>         deleteOrphanedIndices();
>     }
> }
>
> ...it's a wrapper function. You can pull a patch from my
> git-repos, as you like it.
>
>
>
> Olaf Radicke
>
> _______________________________________________
> bt-devel mailing list
> bt-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/bt-devel
>
>   



More information about the bt-devel mailing list