]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add isinline and contenttype filters to metadata list command
authorEric Bollengier <eric@baculasystems.com>
Wed, 23 Feb 2022 17:51:23 +0000 (18:51 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:58 +0000 (13:56 +0200)
bacula/src/cats/cats.c
bacula/src/cats/cats.h
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_output.c

index 7984d289622445c40f04dce574b9a87b51358f5d..1c13e36f1ead1fd06b418291e786512ac3c150ae 100644 (file)
@@ -809,6 +809,17 @@ void META_DBR::create_db_filter(JCR *jcr, BDB *db, POOLMEM **where)
          db->search_op(jcr, "MetaAttachment.AttachmentName", Name, esc.handle(), tmp.handle());
          append_AND_OR_filter(and_or, where, tmp.c_str());
       }
+
+      if (isInline >= 0) {
+         Mmsg(tmp, " MetaAttachment.AttachmentIsInline = %d", isInline);
+         append_filter(where, tmp.c_str());
+      }
+
+      if (ContentType[0]) {
+         db_escape_string(jcr, jcr->db, esc.c_str(), ContentType, strlen(ContentType));
+         Mmsg(tmp, " MetaAttachment.AttachmentContentType = '%s'", esc.c_str());
+         append_filter(where, tmp.c_str());
+      }
    }
 
    if (Owner[0]) {
index d398aaf4c322fb406f7c7f4cbcf20e8113760040..6974f99e104653d194ee105dd062577f815e12e3 100644 (file)
@@ -650,6 +650,7 @@ public:
    int     HasAttachment;
    int     isDraft;
    int     isRead;
+   int     isInline;
    uint64_t offset;
    uint32_t limit;
    int     order;
@@ -675,15 +676,18 @@ public:
    char    Plugin[MAX_NAME_LENGTH];
    char    Name[MAX_SEARCH_LENGTH];
    char    FolderName[MAX_SEARCH_LENGTH];
+   char    ContentType[MAX_SEARCH_LENGTH];
    char    errmsg[MAX_NAME_LENGTH];
    META_DBR(): MinSize(-1), MaxSize(-1), HasAttachment(-1),
-               isDraft(-1), isRead(-1), offset(0), limit(512), order(0), orderby(0), all(false)
+               isDraft(-1), isRead(-1), isInline(-1), offset(0), limit(512),
+               order(0), orderby(0), all(false)
    {
       JobIds = NULL;
       *Id = *Tenant = *Owner = 0;
       *ClientName = *From = *To = *Cc = *Subject = *Tags = 0;
       *BodyPreview = *Type = *ConversationId = *Category = 0;
       *FolderName = *Name = *MinTime = *MaxTime = *Plugin = 0;
+      *ContentType = 0;
       *errmsg = 0;
    };
    ~META_DBR() {};
index 5a5394588e0aef9459eeeec9d8b3ba91b1b48967..fc9859bdcdb8db509d615c4a485f3fd78ce30e94 100644 (file)
@@ -143,7 +143,7 @@ static struct cmdstruct commands[] = {                                      /* C
        "\t    [from=<str> to=<str> cc=<str> tags=<str> subject=<str> bodypreview=<str> all=<str>\n"
        "\t    minsize=<int> maxsize=<int> importance=<str> isread=<0|1> isdraft=<0|1> categories=<str>\n"
        "\t    conversationid=<str> hasattachment=<0|1> starttime=<time> endtime=<time>\n"
-       "\t    emailid=<str> foldername=<str>]\n"
+       "\t    emailid=<str> foldername=<str> isinline=<0|1> contenttype=<str>]\n"
       ), false},
 
  { NT_("llist"),      llist_cmd,     _("Full or long list like list command"),
index 3e1ef5b2d340596f81da33f42460b362821e5a4e..ae6343cb2156758765ec033c0b83e1941607ddf3 100644 (file)
@@ -972,6 +972,9 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
             } else if (strcasecmp(ua->argk[j], NT_("from")) == 0) {
                bstrncpy(meta_r.From, ua->argv[j], sizeof(meta_r.From));
 
+            } else if (strcasecmp(ua->argk[j], NT_("contenttype")) == 0) {
+               bstrncpy(meta_r.ContentType, ua->argv[j], sizeof(meta_r.ContentType));
+
             } else if (strcasecmp(ua->argk[j], NT_("name")) == 0) {
                bstrncpy(meta_r.Name, ua->argv[j], sizeof(meta_r.Name));
 
@@ -1042,6 +1045,9 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
             } else if (strcasecmp(ua->argk[j], NT_("isread")) == 0) {
                meta_r.isRead = str_to_uint64(ua->argv[j]);
 
+            } else if (strcasecmp(ua->argk[j], NT_("isinline")) == 0) {
+               meta_r.isInline = str_to_uint64(ua->argv[j]);
+
             } else if (strcasecmp(ua->argk[j], NT_("isdraft")) == 0) {
                meta_r.isDraft = str_to_uint64(ua->argv[j]);