Esempio n. 1
0
void
expire(const symboldb_options &opt, database &db)
{
  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring URL cache\n");
  }
  db.expire_url_cache();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring unreferenced packages\n");
  }
  db.expire_packages();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring file contents\n");
  }
  db.expire_file_contents();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring java classes\n");
  }
  db.expire_java_classes();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring unused RPMs\n");
  }
  {
    typedef std::vector<std::vector<unsigned char> > digvec;
    std::tr1::shared_ptr<file_cache> fcache(opt.rpm_cache());
    digvec fcdigests;
    fcache->digests(fcdigests);
    std::sort(fcdigests.begin(), fcdigests.end());
    digvec dbdigests;
    db.referenced_package_digests(dbdigests);
    digvec result;
    std::set_difference(fcdigests.begin(), fcdigests.end(),
			dbdigests.begin(), dbdigests.end(),
			std::back_inserter(result));
    fd_handle dir;
    dir.open_directory(opt.rpm_cache_path().c_str());
    for (digvec::iterator p = result.begin(), end = result.end();
	 p != end; ++p) {
      dir.unlinkat(base16_encode(p->begin(), p->end()).c_str(), 0);
    }
  }
}
Esempio n. 2
0
static int
do_show_stale_cached_rpms(const symboldb_options &opt, database &db)
{
  typedef std::vector<std::vector<unsigned char> > digvec;
  std::tr1::shared_ptr<file_cache> fcache(opt.rpm_cache());
  digvec fcdigests;
  fcache->digests(fcdigests);
  std::sort(fcdigests.begin(), fcdigests.end());
  digvec dbdigests;
  db.referenced_package_digests(dbdigests);
  digvec result;
  std::set_difference(fcdigests.begin(), fcdigests.end(),
		      dbdigests.begin(), dbdigests.end(),
		      std::back_inserter(result));
  for (digvec::iterator p = result.begin(), end = result.end();
       p != end; ++p) {
    printf("%s\n", base16_encode(p->begin(), p->end()).c_str());
  }
  return 0;
}