]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_label.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / dird / ua_label.c
index 27af6a471ce35e2071e3b3e51cf807a86ffcec30..0e3a0e050cc6aa8c41241b738c4441d48927a4e1 100644 (file)
@@ -148,8 +148,8 @@ static int do_label(UAContext *ua, char *cmd, int relabel)
    char dev_name[MAX_NAME_LENGTH];
    MEDIA_DBR mr, omr;
    POOL_DBR pr;
+   bool print_reminder = true;
    int ok = FALSE;
-   int mounted = FALSE;
    int i;
    bool media_record_exists = false;
    static char *barcode_keyword[] = {
@@ -284,12 +284,17 @@ checkName:
            /* Here we can get
             *  3001 OK mount. Device=xxx      or
             *  3001 Mounted Volume vvvv
+            *  3906 is cannot mount non-tape
+            * So for those, no need to print a reminder
             */
-            mounted = strncmp(sd->msg, "3001 ", 5) == 0;
+            if (strncmp(sd->msg, "3001 ", 5) == 0 ||
+                strncmp(sd->msg, "3906 ", 5) == 0) {
+              print_reminder = false;
         }
       }
    }
-   if (!mounted) {
+   }
+   if (!print_reminder) {
       bsendmsg(ua, _("Do not forget to mount the drive!!!\n"));
    }
    bnet_sig(sd, BNET_TERMINATE);
@@ -355,14 +360,21 @@ static void label_from_barcodes(UAContext *ua)
        *  send_label_request() below
        */
       if (is_cleaning_tape(ua, &mr, &pr)) {
-        set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
-        if (db_create_media_record(ua->jcr, ua->db, &mr)) {
-            bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"),
-              mr.VolumeName);
-        } else {
-            bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db));
+        if (media_record_exists) {      /* we update it */
+           mr.VolBytes = 1;
+           if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
+                bsendmsg(ua, "%s", db_strerror(ua->db));
+           }
+        } else {                        /* create the media record */
+           set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
+           if (db_create_media_record(ua->jcr, ua->db, &mr)) {
+               bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"),
+                 mr.VolumeName);
+           } else {
+               bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db));
+           }
         }
-        continue;
+        continue;                    /* done, go handle next volume */
       }
       bstrncpy(mr.MediaType, store->media_type, sizeof(mr.MediaType));
       if (ua->jcr->store_bsock) {