[Libreoffice-commits] online.git: common/FileUtil.cpp
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 20 14:38:58 UTC 2020
common/FileUtil.cpp | 61 ----------------------------------------------------
1 file changed, 61 deletions(-)
New commits:
commit fdf5687d7c76d8bea3268bcc65a42fcfc45b1877
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Apr 20 16:30:05 2020 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Mon Apr 20 16:38:40 2020 +0200
Bin some dead code, this gets rid of a use of Util::alertAllUsers(), yay
Getting rid of Util::alertAllUsers() calls in arbitrary places is good
because the semi-obscure way in which it works in the multi-process
web-based Online is potentially hard to fit together with the desire
to make the single-process mobile app able to handle several open
documents.
Change-Id: I6055a993ee31941e3592508aac5f0edf6497a836
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92571
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp
index 8f98a76b8..92d5d3dc4 100644
--- a/common/FileUtil.cpp
+++ b/common/FileUtil.cpp
@@ -45,12 +45,6 @@ namespace filesystem = ::std::filesystem;
namespace
{
- void alertAllUsersAndLog(const std::string& message, const std::string& cmd, const std::string& kind)
- {
- LOG_ERR(message);
- Util::alertAllUsers(cmd, kind);
- }
-
#if HAVE_STD_FILESYSTEM
/// Class to delete files when the process ends.
class FileDeleter
@@ -181,61 +175,6 @@ namespace FileUtil
return dstPath;
}
- bool saveDataToFileSafely(const std::string& fileName, const char *data, size_t size)
- {
- const auto tempFileName = fileName + ".temp";
- std::fstream outStream(tempFileName, std::ios::out);
-
- // If we can't create the file properly, just remove it
- if (!outStream.good())
- {
- alertAllUsersAndLog("Creating " + tempFileName + " failed, disk full?", "internal", "diskfull");
- // Try removing both just in case
- std::remove(tempFileName.c_str());
- std::remove(fileName.c_str());
- return false;
- }
- else
- {
- outStream.write(data, size);
- if (!outStream.good())
- {
- alertAllUsersAndLog("Writing to " + tempFileName + " failed, disk full?", "internal", "diskfull");
- outStream.close();
- std::remove(tempFileName.c_str());
- std::remove(fileName.c_str());
- return false;
- }
- else
- {
- outStream.close();
- if (!outStream.good())
- {
- alertAllUsersAndLog("Closing " + tempFileName + " failed, disk full?", "internal", "diskfull");
- std::remove(tempFileName.c_str());
- std::remove(fileName.c_str());
- return false;
- }
- else
- {
- // Everything OK, rename the file to its proper name
- if (std::rename(tempFileName.c_str(), fileName.c_str()) == 0)
- {
- LOG_DBG("Renaming " << tempFileName << " to " << fileName << " OK.");
- return true;
- }
- else
- {
- alertAllUsersAndLog("Renaming " + tempFileName + " to " + fileName + " failed, disk full?", "internal", "diskfull");
- std::remove(tempFileName.c_str());
- std::remove(fileName.c_str());
- return false;
- }
- }
- }
- }
- }
-
#if 1 // !HAVE_STD_FILESYSTEM
static int nftw_cb(const char *fpath, const struct stat*, int type, struct FTW*)
{
More information about the Libreoffice-commits
mailing list