[pmg-devel] [PATCH pmg-api v2 1/2] collect filenames on unpack

Dominik Csapak d.csapak at proxmox.com
Thu Apr 16 10:59:39 CEST 2020


so that we can later match on them

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PMG/Unpack.pm       | 6 +++++-
 src/bin/pmg-smtp-filter | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/PMG/Unpack.pm b/src/PMG/Unpack.pm
index a4ec20e..1de629a 100755
--- a/src/PMG/Unpack.pm
+++ b/src/PMG/Unpack.pm
@@ -259,6 +259,7 @@ sub new {
     $self->{debug} = $param{debug} || 0;
 
     $self->{mime} = {};
+    $self->{filenames} = {};
 
     $self->{ufid} = 0; # counter to creat unique file names
     $self->{udid} = 0; # counter to creat unique dir names
@@ -494,7 +495,10 @@ sub check_quota {
 sub add_glob_mime_type {
     my ($self, $filename) = @_;
 
-    if (my $ct = xdg_mime_get_mime_type_from_file_name (basename ($filename))) {
+    my $basename = basename($filename);
+    $self->{filenames}->{$basename} = 1;
+
+    if (my $ct = xdg_mime_get_mime_type_from_file_name($basename)) {
 	$self->{mime}->{$ct} = 1 if $ct ne 'application/octet-stream';
     }
 }
diff --git a/src/bin/pmg-smtp-filter b/src/bin/pmg-smtp-filter
index 5f1e582..1f30875 100755
--- a/src/bin/pmg-smtp-filter
+++ b/src/bin/pmg-smtp-filter
@@ -584,6 +584,7 @@ sub unpack_entity {
 	    $self->log (3, "$queue->{logid}: unpack failed - $@") if $@;
 
 	    $entity->{PMX_content_types} = $unpack->{mime};
+	    $entity->{PMX_filenames} = $unpack->{filenames};
 
 	    if ($opt_testmode) {
 		my $types = join (", ", sort keys (%{$entity->{PMX_content_types}}));
-- 
2.20.1




More information about the pmg-devel mailing list