]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add 'list metadata' help usage and add Name search for attachment
authorEric Bollengier <eric@baculasystems.com>
Wed, 22 Sep 2021 16:11:38 +0000 (18:11 +0200)
committerEric Bollengier <eric@baculasystems.com>
Wed, 6 Sep 2023 07:49:00 +0000 (09:49 +0200)
bacula/src/cats/cats.c
bacula/src/cats/cats.h
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_output.c

index eed9b5237aff28731aa330b1c46f59e8ac276db5..8cef8a602b3baaa1b4b5c8afd59b9f23e0d4fb46 100644 (file)
@@ -773,7 +773,12 @@ void META_DBR::create_db_filter(JCR *jcr, BDB *db, POOLMEM **where)
       }
    } else {
       if (Id[0] != 0) {
-         db->search_op(jcr, "MetaAttachment.AttachmentEmailId", Id, esc.handle(), tmp.handle());
+         db_escape_string(jcr, jcr->db, esc.c_str(), Id, strlen(Id));
+         Mmsg(tmp, " MetaAttachment.AttachmentEmailId = '%s'", esc.c_str());
+         append_AND_OR_filter(and_or, where, tmp.c_str());
+      }
+      if (Name[0] != 0) {
+         db->search_op(jcr, "MetaAttachment.AttachmentName", Name, esc.handle(), tmp.handle());
          append_AND_OR_filter(and_or, where, tmp.c_str());
       }
    }
index 74c3d66d5752a7e2e1cb06f1985cffb828331948..419d979c8a7521d72fdf0c0a9fd2507f0ebe0afc 100644 (file)
@@ -667,13 +667,14 @@ public:
    char    MinTime[MAX_NAME_LENGTH];
    char    MaxTime[MAX_NAME_LENGTH];
    char    Plugin[MAX_NAME_LENGTH];
+   char    Name[MAX_SEARCH_LENGTH];
    META_DBR(): JobId(0), MinSize(-1), MaxSize(-1), HasAttachment(-1),
                isDraft(-1), isRead(-1), offset(0), limit(512), order(0), orderby(0), all(false)
    {
       *Id = *Tenant = *Owner = 0;
       *ClientName = *From = *To = *Cc = *Subject = *Tags = 0;
       *BodyPreview = *Type = *ConversationId = *Category = 0;
-      *MinTime = *MaxTime = *Plugin = 0;
+      *Name = *MinTime = *MaxTime = *Plugin = 0;
    };
    ~META_DBR() {};
    void get_important_keys(POOLMEM **dest);
index 264167b63629b02317f7a48702e0814d20693d95..a2f6f7382277a3d42d36615881d475d411ed29bb 100644 (file)
@@ -138,6 +138,11 @@ static struct cmdstruct commands[] = {                                      /* C
        "\tevents [type=<str> | limit=<int> | order=<asc|desc> | days=<int> | start=<time-specification> | end=<time-specification> |\n"
        "\t\t source=<str> | code=<str> | type=<str> ]\n"
        "\tobjects [jobid=<jobid> client=<cli> type=<str> | category=<str> | status=<S> | limit=<int> | order=<asc|desc> ]\n"
+       "\tmetadata type=<email|attachment> [jobid=<nn> client=<cc> order=<Asc|desc> limit=<nn> orderby=<time> offset=<nn>]\n"
+       "\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>]\n"
       ), false},
 
  { NT_("llist"),      llist_cmd,     _("Full or long list like list command"),
@@ -146,7 +151,15 @@ static struct cmdstruct commands[] = {                                      /* C
        "\tjoblog jobid=<nn> | pluginrestoreconf jobid=<nn> restoreobjectid=<nn> | snapshot |\n"
        "\tfilemedia jobid=<nn> fileindex=<mm> | clients\n"
        "\tevents [type=<str> | limit=<int> | order=<asc|desc> | days=<int> | start=<time-specification> | end=<time-specification> ]\n"
-       "\tobject [jobid=<jobid> client=<cli> type=<name> category=<str> order=<asc/desc> limit=<n>\n"), false},
+       "\tobject [jobid=<jobid> client=<cli> type=<name> category=<str> order=<asc/desc> limit=<n>\n"
+       "\tmetadata type=<email|attachment> [jobid=<nn> client=<cc> order=<Asc|desc> limit=<nn> orderby=<time>\n"
+       "\t                                  minsize=<nn> maxsize=<nn> offset=<nn>]\n"
+       "\t   [ from=<str> to=<str> cc=<str> tags=<str> subject=<str> bodypreview=<str> all=<str>\n"
+       "\t    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> ]\n"
+       "\t   [ name=<str> emailid=<str> ]\n"
+      ), false},
 
  { NT_("messages"),   messagescmd,   _("Display pending messages"),   NT_(""),    false},
  { NT_("memory"),     memory_cmd,    _("Print current memory usage"), NT_(""),    true},
index 0a84c17a0af28bab279f034f1616c2ba89361dac..04473edd1b72b32bddbf30487e7da4f41b993d9b 100644 (file)
@@ -937,6 +937,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_("name")) == 0) {
+               bstrncpy(meta_r.Name, ua->argv[j], sizeof(meta_r.Name));
+
             } else if (strcasecmp(ua->argk[j], NT_("emailid")) == 0) {
                bstrncpy(meta_r.Id, ua->argv[j], sizeof(meta_r.Id));