Switch the tar appender to use the first entry's information, not the last

This commit is contained in:
Joseph Schorr 2014-10-17 16:24:02 -04:00
parent 01fdfa079f
commit fc09b8ece8

View file

@ -13,7 +13,7 @@ class TarfileAppender(TarLayerFormat):
super(TarfileAppender, self).__init__(self._get_tar_iterator) super(TarfileAppender, self).__init__(self._get_tar_iterator)
self.entries = entries self.entries = entries
self.base_tar_file = base_tar_file self.base_tar_file = base_tar_file
self.last_info = None self.first_info = None
def get_stream(self): def get_stream(self):
return GzipWrap(self.get_generator()) return GzipWrap(self.get_generator())
@ -22,7 +22,8 @@ class TarfileAppender(TarLayerFormat):
pass pass
def check_tar_info(self, tar_info): def check_tar_info(self, tar_info):
self.last_info = tar_info if not self.first_info:
self.first_info = tar_info
return True return True
def _get_tar_iterator(self): def _get_tar_iterator(self):
@ -33,10 +34,10 @@ class TarfileAppender(TarLayerFormat):
# its data. # its data.
def add_entry(arch, dir_path, contents=None): def add_entry(arch, dir_path, contents=None):
info = tarfile.TarInfo(dir_path) info = tarfile.TarInfo(dir_path)
info.uid = self.last_info.uid info.uid = self.first_info.uid
info.gid = self.last_info.gid info.gid = self.first_info.gid
info.mode = self.last_info.mode info.mode = self.first_info.mode
info.mtime = self.last_info.mtime info.mtime = self.first_info.mtime
info.type = tarfile.REGTYPE if contents else tarfile.DIRTYPE info.type = tarfile.REGTYPE if contents else tarfile.DIRTYPE