Discussion:
createrepo/__init__.py
s***@osuosl.org
2011-08-10 18:41:22 UTC
Permalink
createrepo/__init__.py | 8 ++++++++
1 file changed, 8 insertions(+)

New commits:
commit 850b368ced63b2c0b7f2a4f2fb014d1daba7c80c
Author: Seth Vidal <***@fedoraproject.org>
Date: Wed Aug 10 14:40:50 2011 -0400

if we're using --update we make repo cache dirs in /var/tmp

clean them up before we go

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 30f7422..2c63bad 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -1152,9 +1152,17 @@ class MetaDataGenerator:
raise MDError, msg

self._cleanup_tmp_repodata_dir()
+ self._cleanup_update_tmp_dir()
self._write_out_read_pkgs_list()


+ def _cleanup_update_tmp_dir(self):
+ if not self.conf.update:
+ return
+
+ shutil.rmtree(self.oldData._repo.basecachedir, ignore_errors=True)
+ shutil.rmtree(self.oldData._repo.base_persistdir, ignore_errors=True)
+
def _write_out_read_pkgs_list(self):
# write out the read_pkgs_list file with self.read_pkgs
if self.conf.read_pkgs_list:
s***@osuosl.org
2011-08-12 16:17:39 UTC
Permalink
createrepo/__init__.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit b6c41bc9997b6adcb9e5ccd218a8bd938c04983d
Author: Seth Vidal <***@fedoraproject.org>
Date: Fri Aug 12 12:16:57 2011 -0400

I think this is the last of the tmp files which are, apparently, terribly important to clean up

closes: https://bugzilla.redhat.com/show_bug.cgi?id=730330

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 2c63bad..e3c18aa 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -589,7 +589,7 @@ class MetaDataGenerator:
# waitfor the workers to finish and as each one comes in
# open the files they created and write them out to our metadata
# add up the total pkg counts and return that value
- worker_tmp_path = tempfile.mkdtemp()
+ self._worker_tmp_path = tempfile.mkdtemp() # setting this in the base object so we can clean it up later
worker_chunks = split_list_into_equal_chunks(pkgfiles, self.conf.workers)
worker_cmd_dict = {}
worker_jobs = {}
@@ -611,7 +611,7 @@ class MetaDataGenerator:
# make the worker directory
workercmdline = []
workercmdline.extend(base_worker_cmdline)
- thisdir = worker_tmp_path + '/' + str(worker_num)
+ thisdir = self._worker_tmp_path + '/' + str(worker_num)
if checkAndMakeDir(thisdir):
workercmdline.append('--tmpmdpath=%s' % thisdir)
else:
@@ -658,7 +658,7 @@ class MetaDataGenerator:
for (fn, fo) in (('primary.xml', self.primaryfile),
('filelists.xml', self.flfile),
('other.xml', self.otherfile)):
- fnpath = worker_tmp_path + '/' + str(num) + '/' + fn
+ fnpath = self._worker_tmp_path + '/' + str(num) + '/' + fn
if os.path.exists(fnpath):
fo.write(open(fnpath, 'r').read())

@@ -1189,6 +1189,9 @@ class MetaDataGenerator:
% dirbase)
self.errorlog(_('Error was %s') % e)
self.errorlog(_('Please clean up this directory manually.'))
+ # our worker tmp path
+ if hasattr(self, '_worker_tmp_path') and os.path.exists(self._worker_tmp_path):
+ shutil.rmtree(self._worker_tmp_path, ignore_errors=True)

def setup_sqlite_dbs(self, initdb=True):
"""sets up the sqlite dbs w/table schemas and db_infos"""

Loading...