Move the _link function to the __init__ of pypungi to be used by both gather and pungi.

Attempt to hardlink release note files instead of copy them. (helps preserve timestamps)
This commit is contained in:
Jesse Keating 2007-11-07 19:44:12 -05:00 committed by Jesse Keating
parent ab3bcf6194
commit 47b32e3c2d
4 changed files with 18 additions and 15 deletions

View File

@ -1,3 +1,6 @@
* Wed Nov 07 2007 Jesse Keating <jkeating@redhat.com>
- Preserve timestamps on release note files
* Mon Oct 29 2007 Jesse Keating <jkeating@redhat.com>
- Check to see if the cached package is same size or larger and if so remove
it. Otherwise regets will freak out.

View File

@ -68,3 +68,14 @@ def _doRunCommand(command, logger, rundir='/tmp', output=subprocess.PIPE, error=
logger.error(err)
raise OSError, "Got an error from %s: %s" % (command[0], err)
def _link(local, target):
try:
os.link(local, target)
except OSError, e:
if e.errno != 18: # EXDEV
self.logger.error('Got an error linking from cache: %s' % e)
raise OSError, e
# Can't hardlink cross file systems
shutil.copy2(local, target)

View File

@ -293,17 +293,6 @@ class Gather(pypungi.PungiBase):
if not srpm in self.srpmlist:
self.srpmlist.append(srpm)
def _link(self, local, target):
try:
os.link(local, target)
except OSError, e:
if e.errno != 18: # EXDEV
self.logger.error('Got an error linking from cache: %s' % e)
raise OSError, e
# Can't hardlink cross file systems
shutil.copy2(local, target)
def _downloadPackageList(self, polist, relpkgdir):
"""Cycle through the list of package objects and
download them from their respective repos."""
@ -337,7 +326,7 @@ class Gather(pypungi.PungiBase):
self.logger.debug("%s already exists and appears to be complete" % local)
if os.path.exists(target):
os.remove(target) # avoid traceback after interrupted download
self._link(local, target)
pypungi._link(local, target)
continue
elif os.path.exists(local):
# Check to see if the file on disk is bigger, and if so, remove it
@ -355,7 +344,7 @@ class Gather(pypungi.PungiBase):
if not os.path.exists(local) or not os.path.samefile(path, local):
shutil.copy2(path, local)
self._link(local, target)
pypungi._link(local, target)
self.logger.info('Finished downloading packages.')

View File

@ -208,8 +208,8 @@ class Pungi(pypungi.PungiBase):
for filename in filelist:
for regex in fileres:
if regex.match(filename) and not os.path.exists(os.path.join(self.topdir, filename)):
self.logger.info("Copying release note file %s" % filename)
shutil.copy(os.path.join(dirpath, filename), os.path.join(self.topdir, filename))
self.logger.info("Linking release note file %s" % filename)
pypungi._link(os.path.join(dirpath, filename), os.path.join(self.topdir, filename))
self.common_files.append(filename)
# Walk the tree for our dirs