a/src/index/fsindexer.cpp b/src/index/fsindexer.cpp
...
...
28
#include <iostream>
28
#include <iostream>
29
#include <list>
29
#include <list>
30
#include <map>
30
#include <map>
31
#include <algorithm>
31
#include <algorithm>
32
32
33
#include "cstr.h"
33
#include "pathut.h"
34
#include "pathut.h"
34
#include "conftree.h"
35
#include "conftree.h"
35
#include "rclconfig.h"
36
#include "rclconfig.h"
36
#include "fstreewalk.h"
37
#include "fstreewalk.h"
37
#include "rcldb.h"
38
#include "rcldb.h"
...
...
239
{
240
{
240
    if (!init())
241
    if (!init())
241
    return false;
242
    return false;
242
    for (list<string>::iterator it = files.begin(); it != files.end(); ) {
243
    for (list<string>::iterator it = files.begin(); it != files.end(); ) {
243
    string udi;
244
    string udi;
244
    make_udi(*it, "", udi);
245
    make_udi(*it, cstr_null, udi);
245
        // rcldb::purgefile returns true if the udi was either not
246
        // rcldb::purgefile returns true if the udi was either not
246
        // found or deleted, false only in case of actual error
247
        // found or deleted, false only in case of actual error
247
        bool existed;
248
        bool existed;
248
    if (!m_db->purgeFile(udi, &existed)) {
249
    if (!m_db->purgeFile(udi, &existed)) {
249
        LOGERR(("FsIndexer::purgeFiles: Database error\n"));
250
        LOGERR(("FsIndexer::purgeFiles: Database error\n"));
...
...
340
    // against the stored one). Changing the computation forces a full
341
    // against the stored one). Changing the computation forces a full
341
    // reindex of course.
342
    // reindex of course.
342
    string sig;
343
    string sig;
343
    makesig(stp, sig);
344
    makesig(stp, sig);
344
    string udi;
345
    string udi;
345
    make_udi(fn, "", udi);
346
    make_udi(fn, cstr_null, udi);
346
    if (!m_db->needUpdate(udi, sig)) {
347
    if (!m_db->needUpdate(udi, sig)) {
347
    LOGDEB0(("processone: up to date: %s\n", fn.c_str()));
348
    LOGDEB0(("processone: up to date: %s\n", fn.c_str()));
348
    if (m_updater) {
349
    if (m_updater) {
349
        // Status bar update, abort request etc.
350
        // Status bar update, abort request etc.
350
        m_updater->status.fn = fn;
351
        m_updater->status.fn = fn;
...
...
382
    LOGDEB2(("processone: fn transcoded from [%s] to [%s] (%s->%s)\n",
383
    LOGDEB2(("processone: fn transcoded from [%s] to [%s] (%s->%s)\n",
383
         path_getsimple(fn).c_str(), utf8fn.c_str(), charset.c_str(), 
384
         path_getsimple(fn).c_str(), utf8fn.c_str(), charset.c_str(), 
384
         "UTF-8"));
385
         "UTF-8"));
385
386
386
    string parent_udi;
387
    string parent_udi;
387
    make_udi(fn, "", parent_udi);
388
    make_udi(fn, cstr_null, parent_udi);
388
    Rcl::Doc doc;
389
    Rcl::Doc doc;
389
    const string plus("+");
390
    char ascdate[30];
390
    char ascdate[30];
391
    sprintf(ascdate, "%ld", long(stp->st_mtime));
391
    sprintf(ascdate, "%ld", long(stp->st_mtime));
392
392
393
    FileInterner::Status fis = FileInterner::FIAgain;
393
    FileInterner::Status fis = FileInterner::FIAgain;
394
    bool hadNullIpath = false;
394
    bool hadNullIpath = false;
...
...
411
411
412
    // Set file name, mod time and url if not done by filter
412
    // Set file name, mod time and url if not done by filter
413
    if (doc.fmtime.empty())
413
    if (doc.fmtime.empty())
414
        doc.fmtime = ascdate;
414
        doc.fmtime = ascdate;
415
        if (doc.url.empty())
415
        if (doc.url.empty())
416
            doc.url = string("file://") + fn;
416
            doc.url = cstr_fileu + fn;
417
    if (doc.utf8fn.empty())
417
    if (doc.utf8fn.empty())
418
        doc.utf8fn = utf8fn;
418
        doc.utf8fn = utf8fn;
419
419
420
    char cbuf[100]; 
420
    char cbuf[100]; 
421
    sprintf(cbuf, OFFTPC, stp->st_size);
421
    sprintf(cbuf, OFFTPC, stp->st_size);
...
...
430
    // retried. This is for the once missing, later installed
430
    // retried. This is for the once missing, later installed
431
    // filter case. It can make indexing much slower (if there are
431
    // filter case. It can make indexing much slower (if there are
432
    // myriads of such files, the ext script is executed for them
432
    // myriads of such files, the ext script is executed for them
433
    // and fails every time)
433
    // and fails every time)
434
    if (fis == FileInterner::FIError) {
434
    if (fis == FileInterner::FIError) {
435
        doc.sig += plus;
435
        doc.sig += cstr_plus;
436
    }
436
    }
437
437
438
        // Possibly add fields from local config
438
        // Possibly add fields from local config
439
        if (m_havelocalfields) 
439
        if (m_havelocalfields) 
440
            setlocalfields(doc);
440
            setlocalfields(doc);
441
    // Add document to database. If there is an ipath, add it as a children
441
    // Add document to database. If there is an ipath, add it as a children
442
    // of the file document.
442
    // of the file document.
443
    string udi;
443
    string udi;
444
    make_udi(fn, doc.ipath, udi);
444
    make_udi(fn, doc.ipath, udi);
445
    if (!m_db->addOrUpdate(udi, doc.ipath.empty() ? "" : parent_udi, doc)) 
445
    if (!m_db->addOrUpdate(udi, doc.ipath.empty() ? cstr_null : parent_udi, doc)) 
446
        return FsTreeWalker::FtwError;
446
        return FsTreeWalker::FtwError;
447
447
448
    // Tell what we are doing and check for interrupt request
448
    // Tell what we are doing and check for interrupt request
449
    if (m_updater) {
449
    if (m_updater) {
450
        ++(m_updater->status.docsdone);
450
        ++(m_updater->status.docsdone);
...
...
466
    LOGDEB1(("Creating empty doc for file\n"));
466
    LOGDEB1(("Creating empty doc for file\n"));
467
    Rcl::Doc fileDoc;
467
    Rcl::Doc fileDoc;
468
    fileDoc.fmtime = ascdate;
468
    fileDoc.fmtime = ascdate;
469
    fileDoc.utf8fn = utf8fn;
469
    fileDoc.utf8fn = utf8fn;
470
    fileDoc.mimetype = interner.getMimetype();
470
    fileDoc.mimetype = interner.getMimetype();
471
    fileDoc.url = string("file://") + fn;
471
    fileDoc.url = cstr_fileu + fn;
472
472
473
    char cbuf[100]; 
473
    char cbuf[100]; 
474
    sprintf(cbuf, OFFTPC, stp->st_size);
474
    sprintf(cbuf, OFFTPC, stp->st_size);
475
    fileDoc.fbytes = cbuf;
475
    fileDoc.fbytes = cbuf;
476
    // Document signature for up to date checks.
476
    // Document signature for up to date checks.
477
    makesig(stp, fileDoc.sig);
477
    makesig(stp, fileDoc.sig);
478
    if (!m_db->addOrUpdate(parent_udi, "", fileDoc)) 
478
    if (!m_db->addOrUpdate(parent_udi, cstr_null, fileDoc)) 
479
        return FsTreeWalker::FtwError;
479
        return FsTreeWalker::FtwError;
480
    }
480
    }
481
481
482
    return FsTreeWalker::FtwOk;
482
    return FsTreeWalker::FtwOk;
483
}
483
}