summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-02-04 14:43:16 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2019-02-04 14:43:16 +0100
commitcde5ee8fe527d3d672775909d27110d11c393774 (patch)
tree00952d6fac8cd1b5e5fae8a01b9bf24078adc887 /apt-pkg/contrib/fileutl.cc
parent3a015964dd56edf897ee062b2eafa2cfc0584380 (diff)
gpgv: Use buffered writes for splitting clearsigned files
This is safe here, as the code ensures that the file is flushed before it is being used. The next series should probably make GetTempFile() buffer writes by default.
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 8cb4b509c..0c0cb05ea 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -3107,6 +3107,10 @@ std::string GetTempDir(std::string const &User)
/*}}}*/
FileFd* GetTempFile(std::string const &Prefix, bool ImmediateUnlink, FileFd * const TmpFd) /*{{{*/
{
+ return GetTempFile(Prefix, ImmediateUnlink, TmpFd, false);
+}
+FileFd* GetTempFile(std::string const &Prefix, bool ImmediateUnlink, FileFd * const TmpFd, bool Buffered)
+{
char fn[512];
FileFd * const Fd = TmpFd == nullptr ? new FileFd() : TmpFd;
@@ -3123,7 +3127,7 @@ FileFd* GetTempFile(std::string const &Prefix, bool ImmediateUnlink, FileFd * co
delete Fd;
return nullptr;
}
- if (!Fd->OpenDescriptor(fd, FileFd::ReadWrite, FileFd::None, true))
+ if (!Fd->OpenDescriptor(fd, FileFd::ReadWrite | (Buffered ? FileFd::BufferedWrite : 0), FileFd::None, true))
{
_error->Errno("GetTempFile",_("Unable to write to %s"),fn);
if (TmpFd == nullptr)