a/src/index/fsfetcher.cpp b/src/index/fsfetcher.cpp
...
...
29
#include "fsindexer.h"
29
#include "fsindexer.h"
30
#include "debuglog.h"
30
#include "debuglog.h"
31
31
32
using std::string;
32
using std::string;
33
33
34
static bool urltopath(RclConfig* cnf,
34
static bool urltopath(const Rcl::Doc& idoc, string& fn, struct stat& st)
35
            const Rcl::Doc& idoc, string& fn, struct stat& st)
35
{
36
{
36
    // The url has to be like file://
37
    // The url has to be like file://
37
    if (idoc.url.find(cstr_fileu) != 0) {
38
    if (idoc.url.find(cstr_fileu) != 0) {
38
    LOGERR(("FSDocFetcher::fetch/sig: non fs url: [%s]\n", 
39
    LOGERR(("FSDocFetcher::fetch/sig: non fs url: [%s]\n", 
39
        idoc.url.c_str()));
40
        idoc.url.c_str()));
40
    return false;
41
    return false;
41
    }
42
    }
42
    fn = idoc.url.substr(7, string::npos);
43
    fn = idoc.url.substr(7, string::npos);
43
    if (stat(fn.c_str(), &st) < 0) {
44
    cnf->setKeyDir(path_getfather(fn));
45
    bool follow = false;
46
    cnf->getConfParam("followLinks", &follow);
47
48
    if ((follow ? stat(fn.c_str(), &st) : lstat(fn.c_str(), &st))< 0) {
44
    LOGERR(("FSDocFetcher::fetch: stat errno %d for [%s]\n", 
49
    LOGERR(("FSDocFetcher::fetch: stat errno %d for [%s]\n", 
45
        errno, fn.c_str()));
50
        errno, fn.c_str()));
46
    return false;
51
    return false;
47
    }
52
    }
48
    return true;
53
    return true;
49
}
54
}
50
55
51
bool FSDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
56
bool FSDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
52
{
57
{
53
    string fn;
58
    string fn;
54
    if (!urltopath(idoc, fn, out.st))
59
    if (!urltopath(cnf, idoc, fn, out.st))
55
    return false;
60
    return false;
56
    out.kind = RawDoc::RDK_FILENAME;
61
    out.kind = RawDoc::RDK_FILENAME;
57
    out.data = fn;
62
    out.data = fn;
58
    return true;
63
    return true;
59
}
64
}
60
    
65
    
61
bool FSDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig)
66
bool FSDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig)
62
{
67
{
63
    string fn;
68
    string fn;
64
    struct stat st;
69
    struct stat st;
65
    if (!urltopath(idoc, fn, st))
70
    if (!urltopath(cnf, idoc, fn, st))
66
    return false;
71
    return false;
67
    FsIndexer::makesig(&st, sig);
72
    FsIndexer::makesig(&st, sig);
68
    return true;
73
    return true;
69
}
74
}
70
75