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

truncating /dev/null to zero is always successful

Calling truncate on /dev/null can happen by the download methods if they
are instructed to download a file to /dev/null (as testcases are only
interested in the status code, but do not support HEAD requests yet)

So just ignore truncate calls on the /dev/null file as it is always
empty anyway, so truncating to zero isn't a problem.

Git-Dch: Ignore
David Kalnischkies лет назад: 12
Родитель
Сommit
ad5051ef9d
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      apt-pkg/contrib/fileutl.cc

+ 3 - 0
apt-pkg/contrib/fileutl.cc

@@ -1545,6 +1545,9 @@ bool FileFd::Skip(unsigned long long Over)
 /* */
 bool FileFd::Truncate(unsigned long long To)
 {
+   // truncating /dev/null is always successful - as we get an error otherwise
+   if (To == 0 && FileName == "/dev/null")
+      return true;
 #if defined HAVE_ZLIB || defined HAVE_BZ2
    if (d != NULL && (d->gz != NULL || d->bz2 != NULL))
       return FileFdError("Truncating compressed files is not implemented (%s)", FileName.c_str());