Kaydet (Commit) 38afe297 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#119050 sfx2 store: don't inherit temp file permissions when overwriting

The too aggressive error handling in commit
fb04780c (tdf#116117 sfx2 store: don't
inherit temp file permissions when renaming, 2018-03-12) means that if
the file is already there, then we don't try to stat() it; even if there
is no problem with that.

Change-Id: Ie0b9084064834e339bcae3ad7b4a35c54cb9d3c2
Reviewed-on: https://gerrit.libreoffice.org/59684Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
üst 29591a97
......@@ -146,6 +146,14 @@ void MiscTest::testNoThumbnail()
// umask requested so:
CPPUNIT_ASSERT(aStatus.getAttributes() & osl_File_Attribute_GrpRead);
CPPUNIT_ASSERT(aStatus.getAttributes() & osl_File_Attribute_OthRead);
// Now "save as" again to trigger the "overwrite" case.
xStorable->storeToURL(aTempFile.GetURL(), {});
CPPUNIT_ASSERT_EQUAL(osl::DirectoryItem::E_None, aItem.getFileStatus(aStatus));
// The following check used to fail in the past, result had temp file
// permissions.
CPPUNIT_ASSERT(aStatus.getAttributes() & osl_File_Attribute_GrpRead);
umask(nMask);
#endif
......
......@@ -180,8 +180,10 @@ sal_uInt64 GetDefaultFileAttributes(const OUString& rURL)
if (!comphelper::isFileUrl(rURL))
return nRet;
// Make sure the file exists (and create it if not).
osl::File aFile(rURL);
if (aFile.open(osl_File_OpenFlag_Create) != osl::File::E_None)
osl::File::RC nRes = aFile.open(osl_File_OpenFlag_Create);
if (nRes != osl::File::E_None && nRes != osl::File::E_EXIST)
return nRet;
aFile.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment