From c94f763283c55e73ec32947c31a6f4f2e89b2764 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Fri, 14 Dec 2012 11:38:43 +0200 Subject: [PATCH] TransRead: improve file size detection In case of a tar archive, we know the file size for 'TarInfo'. Propagate it to the users via our 'size' attribute. Change-Id: I11dc7daa1d788fe98769ba6537f4117d89d06b34 Signed-off-by: Artem Bityutskiy --- bmaptools/TransRead.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bmaptools/TransRead.py b/bmaptools/TransRead.py index 6de6e75..58f067d 100644 --- a/bmaptools/TransRead.py +++ b/bmaptools/TransRead.py @@ -33,7 +33,7 @@ class TransRead: tar = tarfile.open(self.filepath, 'r') # The tarball is supposed to contain only one single member - members = tar.getnames() + members = tar.getmembers() if len(members) > 1: raise Error("tarball '%s' contains more than one file" \ % self.filepath) @@ -42,6 +42,7 @@ class TransRead: % self.filepath) self._transfile_obj = tar.extractfile(members[0]) + self.size = members[0].size elif self.filepath.endswith('.gz'): import gzip -- 2.7.4