fsync() in posixFile::fileCreate(); changed posixFile::rename to exclusive semantics - if dst exists it fails (Georg Sauthoff).
This commit is contained in:
parent
a67f0a537e
commit
f36ccb2558
@ -284,6 +284,9 @@ void posixFile::createFile()
|
||||
if ((fd = ::open(m_nativePath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660)) == -1)
|
||||
posixFileSystemFactory::reportError(m_path, errno);
|
||||
|
||||
if (::fsync(fd) == -1)
|
||||
posixFileSystemFactory::reportError(m_path, errno);
|
||||
|
||||
if (::close(fd) == -1)
|
||||
posixFileSystemFactory::reportError(m_path, errno);
|
||||
}
|
||||
@ -390,6 +393,9 @@ void posixFile::rename(const path& newName)
|
||||
{
|
||||
const vmime::string newNativePath = posixFileSystemFactory::pathToStringImpl(newName);
|
||||
|
||||
posixFile dest(newName);
|
||||
dest.createFile();
|
||||
|
||||
if (::rename(m_nativePath.c_str(), newNativePath.c_str()) == -1)
|
||||
posixFileSystemFactory::reportError(m_path, errno);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user