Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2016-06-26 15:39:22 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2016-06-26 15:43:19 +0300
commit04684104a172dc7a2d3d52d2667881922ef097d0 (patch)
tree8ecde5e0f481338484b1749c5b91b1b95d3b3fea
parent411fe5b272ffd1a678c83b4f8f32a52ac79d8778 (diff)
Permit the upload of a compressed empty file as a package file20160629
Permit the upload of a compressed empty file as a package file Adjust a test pacakge to exercise that case
-rw-r--r--calm/uploads.py22
-rw-r--r--test/testdata/homes/Blooey McFooey/x86/release/testpackage2/testpackage2-subpackage/testpackage2-subpackage-1.0-1.tar.bz2bin195 -> 14 bytes
-rw-r--r--test/testdata/uploads/pkglist.expected2
3 files changed, 14 insertions, 10 deletions
diff --git a/calm/uploads.py b/calm/uploads.py
index 59c3d70..d2d75ee 100644
--- a/calm/uploads.py
+++ b/calm/uploads.py
@@ -170,15 +170,19 @@ def scan(m, all_packages, arch, args):
# verify compressed archive files are valid
if re.search(r'\.tar\.(bz2|gz|lzma|xz)$', f):
valid = True
- try:
- # we need to extract all of an archive contents to validate
- # it
- with tarfile.open(fn) as a:
- a.getmembers()
- except Exception as e:
- valid = False
- logging.error("exception %s while reading %s" % (type(e).__name__, fn))
- logging.debug('', exc_info=True)
+
+ # accept a compressed empty file, even though it isn't a valid
+ # compressed archive
+ if os.path.getsize(fn) > 32:
+ try:
+ # we need to extract all of an archive contents to validate
+ # it
+ with tarfile.open(fn) as a:
+ a.getmembers()
+ except Exception as e:
+ valid = False
+ logging.error("exception %s while reading %s" % (type(e).__name__, fn))
+ logging.debug('', exc_info=True)
if not valid:
files.remove(f)
diff --git a/test/testdata/homes/Blooey McFooey/x86/release/testpackage2/testpackage2-subpackage/testpackage2-subpackage-1.0-1.tar.bz2 b/test/testdata/homes/Blooey McFooey/x86/release/testpackage2/testpackage2-subpackage/testpackage2-subpackage-1.0-1.tar.bz2
index a1145fb..b56f3b9 100644
--- a/test/testdata/homes/Blooey McFooey/x86/release/testpackage2/testpackage2-subpackage/testpackage2-subpackage-1.0-1.tar.bz2
+++ b/test/testdata/homes/Blooey McFooey/x86/release/testpackage2/testpackage2-subpackage/testpackage2-subpackage-1.0-1.tar.bz2
Binary files differ
diff --git a/test/testdata/uploads/pkglist.expected b/test/testdata/uploads/pkglist.expected
index bbe52b0..695aa09 100644
--- a/test/testdata/uploads/pkglist.expected
+++ b/test/testdata/uploads/pkglist.expected
@@ -9,6 +9,6 @@
'ldesc': '"A test subpackage"',
'category': 'Devel',
'external-source': 'testpackage'}),
- 'testpackage2-subpackage': Package('x86/release/testpackage2/testpackage2-subpackage', {'testpackage2-subpackage-1.0-1.tar.bz2': Tar('aff488008bee3486e25b539fe6ccd1397bd3c5c0ba2ee2cf34af279554baa195af7493ee51d6f8510735c9a2ea54436d776a71e768165716762aec286abbbf83', 195, False)}, {'sdesc': '"A test subpackage 2"',
+ 'testpackage2-subpackage': Package('x86/release/testpackage2/testpackage2-subpackage', {'testpackage2-subpackage-1.0-1.tar.bz2': Tar('6de201dfed1d45412509c65deb34690dc2d09c6aafccfe491fd2f440f92842b9c755b61dc7bcdd4cc0c9f18cf46c2b3a1241e99c4c2a33fff5555e7b2f0b6348', 14, True)}, {'sdesc': '"A test subpackage 2"',
'ldesc': '"A test subpackage 2"',
'category': 'Devel'})}