Просмотр исходного кода

allow uncompressed files to be empty in store again

With the previous fix for file applied we can again hit repositories
which contain uncompressed empty files, which since the introduction of
the central store: method wasn't accounted for anymore as we forbid
empty compressed files.
David Kalnischkies лет назад: 10
Родитель
Сommit
479f6fa454
2 измененных файлов с 26 добавлено и 1 удалено
  1. 1 1
      methods/store.cc
  2. 25 0
      test/integration/test-apt-update-empty-files

+ 1 - 1
methods/store.cc

@@ -73,7 +73,7 @@ bool StoreMethod::Fetch(FetchItem *Itm)					/*{{{*/
    {
    {
       if (OpenFileWithCompressorByName(From, Path, FileFd::ReadOnly, Prog) == false)
       if (OpenFileWithCompressorByName(From, Path, FileFd::ReadOnly, Prog) == false)
 	 return false;
 	 return false;
-      if(From.FileSize() == 0)
+      if(From.IsCompressed() && From.FileSize() == 0)
 	 return _error->Error(_("Empty files can't be valid archives"));
 	 return _error->Error(_("Empty files can't be valid archives"));
    }
    }
    else
    else

+ 25 - 0
test/integration/test-apt-update-empty-files

@@ -0,0 +1,25 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'amd64'
+configcompression '.' 'gz'
+
+insertpackage 'unstable' 'apt' 'amd64' '1'
+# this automatically gives us an empty Sources file
+
+setupaptarchive --no-update
+
+msgmsg 'Test with file'
+rm -rf rootdir/var/lib/apt/lists
+testsuccess apt update -o Debug::pkgAcquire::Worker=1
+cp rootdir/tmp/testsuccess.output apt.output
+testsuccess grep '%0aAlt-Filename:%20/.*/Sources%0a' apt.output
+
+msgmsg 'Test with http'
+changetowebserver
+rm -rf rootdir/var/lib/apt/lists
+testsuccess apt update -o Debug::pkgAcquire::Worker=1