~jamesh/mediascanner/qml-plugin

« back to all changes in this revision

Viewing changes to src/daemon/SubtreeWatcher.cc

  • Committer: Tarmac
  • Author(s): James Henstridge
  • Date: 2013-11-28 14:24:00 UTC
  • mfrom: (186.1.14 etag)
  • Revision ID: tarmac-20131128142400-72plan6tn4bl9dlr
Store the etag of files in the MediaStore so the scanner can detect whether it is necessary to redo the metadata extraction on files on start up.

Approved by PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
void SubtreeWatcher::fileAdded(const string &abspath) {
128
128
    printf("New file was created: %s.\n", abspath.c_str());
129
129
    try {
130
 
        MediaFile m = p->extractor.extract(abspath);
131
 
        p->store.insert(m);
 
130
        DetectedFile d = p->extractor.detect(abspath);
 
131
        // Only extract and insert the file if the ETag has changed.
 
132
        if (d.etag != p->store.getETag(d.filename)) {
 
133
            p->store.insert(p->extractor.extract(d));
 
134
        }
132
135
    } catch(const exception &e) {
133
136
        fprintf(stderr, "Error when adding new file: %s\n", e.what());
134
137
    }