/* * Unlink file on local or remote host. */ static void unlinkFile( char *name) { int rval = 0; char *host; host = DiskVolsGetHostname(diskVolume); if (host) { cemit(TO_FILE, 0, 20310, host, name); } else { cemit(TO_FILE, 0, 20311, name); } if (ignoreRecycling == B_FALSE) { rval = SamrftUnlink(rft, name); } if (rval == 0) { numRecycledFiles++; } }
/// operator() overload, constant /// \note /// This contains the same implementation as cemit(), it is simply an easier way to call emit(). /// It is useful for when you need an event_queue to act as a functor. void operator()() const { cemit(); }
/// Emits out queued up events, and then clears the queued events. /// \see cemit If you wish for you data to not be cleared. void emit() { cemit(); // emit events clear(); // clear out data }
/* * Recycle vsn. */ static void recycle( VSN_TABLE *vsn) { char *host; ROBOT_TABLE *robot = NULL; struct DiskVolsDictionary *diskvols; /* * Set archive set. */ robot = vsn->robot; if (robot == NULL) { Trace(TR_ERR, "Could not find disk archive set for volume '%s'", vsn->vsn); return; } Trace(TR_MISC, "[%s] Recycling disk volume minobs: %d%% dataquantity: %s (%d)", vsn->vsn, robot->obs, StrFromFsize(robot->dataquantity, 3, NULL, 0), robot->limit_quantity); Trace(TR_MISC, "[%s] Needs recycling: %d ignore: %d candidate: %d", vsn->vsn, vsn->needs_recycling, ignoreRecycling, vsn->candidate); /* Recycling disk archive set */ cemit(TO_FILE, 0, 20308, robot->name, vsn->vsn); if (IS_DISK_HONEYCOMB(vsn->media)) { /* * Metadata records for the following list of OIDs * will be deleted. */ cemit(TO_FILE, 0, 20354); } else { /* * The following list of files and directories will be removed. */ cemit(TO_FILE, 0, 20355); } if (ignoreRecycling) { cemit(TO_FILE, 0, 20309); } diskVolume = NULL; diskvols = DiskVolsGetHandle(DISKVOLS_VSN_DICT); if (diskvols != NULL) { (void) diskvols->Get(diskvols, (char *)&vsn->vsn[0], &diskVolume); } if (diskVolume == NULL) { Trace(TR_ERR, "Could not find disk volume '%s'", (char *)&vsn->vsn[0]); goto out; } host = DiskVolsGetHostname(diskVolume); rft = SamrftConnect(host); if (rft == NULL) { if (host == NULL) { host = ""; } Trace(TR_ERR, "Sam rft connection to '%s' failed", host); goto out; } numRecycledFiles = 0; /* * Recycle sequence numbers. Any sequence number not * being used are mapped to files which can be removed from the * disk archive volume. */ recycleSeqNumbers(robot, vsn); if (rft != NULL) { SamrftDisconnect(rft); rft = NULL; } if (diskVolume->DvFlags & DV_remote) { cemit(TO_FILE, 0, 20302, numRecycledFiles, vsn->vsn, diskVolume->DvHost, diskVolume->DvPath); } else { cemit(TO_FILE, 0, 20303, numRecycledFiles, vsn->vsn, diskVolume->DvPath); } if (robot->mail && ignoreRecycling == B_FALSE) { char *fmt; char *subject; char *mailaddr; FILE *mailfile; subject = catgets(catfd, SET, 20257, "Message number 20257"); mailaddr = robot->mailaddress; mailfile = Mopen(mailaddr); if (mailfile != NULL) { if (diskVolume->DvFlags & DV_remote) { fmt = catgets(catfd, SET, 20302, "Message number 20302"); fprintf(mailfile, fmt, numRecycledFiles, vsn->vsn, diskVolume->DvHost, diskVolume->DvPath); fprintf(mailfile, "\n"); } else { fmt = catgets(catfd, SET, 20303, "Message number 20303"); fprintf(mailfile, fmt, numRecycledFiles, vsn->vsn, diskVolume->DvPath); fprintf(mailfile, "\n"); } Msend(&mailfile, mailaddr, subject); } } out: DiskVolsRelHandle(DISKVOLS_VSN_DICT); }