From 232b71b34b04de3c6920aa48951383448d2dd748 Mon Sep 17 00:00:00 2001 From: Paul Varache Date: Thu, 16 Apr 2015 17:43:20 +0200 Subject: [PATCH 1/2] [AWS] Added interval and listenTo properties --- aws/aws.html | 14 ++++++++++++++ aws/aws.js | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/aws/aws.html b/aws/aws.html index 28e50778..a43cb139 100644 --- a/aws/aws.html +++ b/aws/aws.html @@ -27,6 +27,18 @@ +
+ + +
+
+ + +
@@ -51,6 +63,8 @@ bucket: {required:true}, filepattern: {value:""}, name: {value:""}, + interval: {value: 900000}, + listenTo: {value: 'add'} }, inputs:0, outputs:1, diff --git a/aws/aws.js b/aws/aws.js index 2b09018e..1c42306f 100644 --- a/aws/aws.js +++ b/aws/aws.js @@ -43,6 +43,8 @@ module.exports = function(RED) { this.awsConfig = RED.nodes.getNode(n.aws); this.region = n.region; this.bucket = n.bucket; + this.interval = n.interval || 900000; + this.listenTo = n.listenTo || "add"; this.filepattern = n.filepattern || ""; var node = this; var AWS = this.awsConfig ? this.awsConfig.AWS : null; @@ -81,7 +83,7 @@ module.exports = function(RED) { var file = newContents[i].Key; if (seen[file]) { delete seen[file]; - } else { + } else if(node.listenTo === "add" || node.listenTo === "all"){ msg.payload = file; msg.file = file.substring(file.lastIndexOf('/')+1); msg.event = 'add'; @@ -90,7 +92,7 @@ module.exports = function(RED) { } } for (var f in seen) { - if (seen.hasOwnProperty(f)) { + if (seen.hasOwnProperty(f) && node.listenTo === "delete" || node.listenTo === "all") { msg.payload = f; msg.file = f.substring(f.lastIndexOf('/')+1); msg.event = 'delete'; @@ -103,7 +105,7 @@ module.exports = function(RED) { }); var interval = setInterval(function() { node.emit("input", {}); - }, 900000); // 15 minutes + }, node.interval); // 15 minutes node.on("close", function() { if (interval !== null) { clearInterval(interval); From 4056a08b888d0736288a403a58e8d4a89c5d7883 Mon Sep 17 00:00:00 2001 From: Paul Varache Date: Thu, 16 Apr 2015 17:51:05 +0200 Subject: [PATCH 2/2] [AWS] Removed listenTo as you can do it with a switch node --- aws/aws.html | 11 +---------- aws/aws.js | 5 ++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/aws/aws.html b/aws/aws.html index a43cb139..1b65a3cf 100644 --- a/aws/aws.html +++ b/aws/aws.html @@ -31,14 +31,6 @@
-
- - -
@@ -63,8 +55,7 @@ bucket: {required:true}, filepattern: {value:""}, name: {value:""}, - interval: {value: 900000}, - listenTo: {value: 'add'} + interval: {value: 900000} }, inputs:0, outputs:1, diff --git a/aws/aws.js b/aws/aws.js index 1c42306f..173b973b 100644 --- a/aws/aws.js +++ b/aws/aws.js @@ -44,7 +44,6 @@ module.exports = function(RED) { this.region = n.region; this.bucket = n.bucket; this.interval = n.interval || 900000; - this.listenTo = n.listenTo || "add"; this.filepattern = n.filepattern || ""; var node = this; var AWS = this.awsConfig ? this.awsConfig.AWS : null; @@ -83,7 +82,7 @@ module.exports = function(RED) { var file = newContents[i].Key; if (seen[file]) { delete seen[file]; - } else if(node.listenTo === "add" || node.listenTo === "all"){ + } else { msg.payload = file; msg.file = file.substring(file.lastIndexOf('/')+1); msg.event = 'add'; @@ -92,7 +91,7 @@ module.exports = function(RED) { } } for (var f in seen) { - if (seen.hasOwnProperty(f) && node.listenTo === "delete" || node.listenTo === "all") { + if (seen.hasOwnProperty(f)) { msg.payload = f; msg.file = f.substring(f.lastIndexOf('/')+1); msg.event = 'delete';