added support for source_content_type in os_daemon config

pull/20/head
Felix Schauerte 9 years ago
parent ca8959f07d
commit b71414f431

@ -60,6 +60,9 @@ timeout = 60000
; Ignore the following databases (again comma separated list)
; Regular expressions are again allowed:
blacklist = /^_/
; Only attachments which match any of the mime types below are processed (separate with comma).
; Default is /^image\// Regular expressions are allowed:
;source_content_types = /^image\//,application/postscript
```
## Imagemagick Configuration

@ -11,6 +11,18 @@ var nano = require('nano');
var strformat = require('strformat');
var docuri = require('docuri');
function compileRegexp(string) {
if (string instanceof RegExp) {
return string;
}
if (string.match(/^\/.*\/$/)) {
string = string.slice(1, string.length - 1);
} else {
string = '^' + string + '$';
}
return new RegExp(string);
}
// TODO: emit all documents, also filtered one, to enable checkpointing
module.exports = function couchmagick(url, options) {
@ -18,6 +30,15 @@ module.exports = function couchmagick(url, options) {
options.concurrency = options.concurrency || 1;
options.timeout = options.timeout || 60 * 1000; // 1 minute
options.source_content_types = options.source_content_types ?
options.source_content_types.split(/,\s*/) : [/^image\//];
if (options.source_content_types) {
if (!Array.isArray(options.source_content_types)) {
options.source_content_types = [options.source_content_types];
}
options.source_content_types = options.source_content_types.map(compileRegexp);
}
var couch = nano(url);
var configs = {};
@ -224,7 +245,10 @@ module.exports = function couchmagick(url, options) {
return false;
}
return data.doc._attachments[data.name].content_type.match(/^image\//);
var content_type = data.doc._attachments[data.name].content_type;
return options.source_content_types.some(function(r) {
return content_type.match(r);
});
}),
// split stream into versions

Loading…
Cancel
Save