[Libreoffice-commits] core.git: Branch 'feature/profilesafemode' - comphelper/source configmgr/source desktop/source include/comphelper

Armin Le Grand Armin.Le.Grand at cib.de
Fri Sep 30 08:24:02 UTC 2016


 comphelper/source/misc/backupfilehelper.cxx |   12 ++++--------
 configmgr/source/components.cxx             |    2 --
 desktop/source/app/app.cxx                  |    5 ++++-
 include/comphelper/backupfilehelper.hxx     |   23 ++++++++++++++++++++---
 4 files changed, 28 insertions(+), 14 deletions(-)

New commits:
commit f820dd74d810534c6659d75d0d5bb1720529395a
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Fri Sep 30 10:12:20 2016 +0200

    profilesafe: Added flag for compress
    
    Added more handy flag for choose if added files
    should be compressed, some cleanups#
    
    Change-Id: I9c4f5aff58a2807605a9fa1fdd650b7fd64c7ba3

diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index e02a855..5d920d8 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -669,7 +669,7 @@ namespace
             return bRetval;
         }
 
-        bool tryPush(FileSharedPtr& rFileCandidate)
+        bool tryPush(FileSharedPtr& rFileCandidate, bool bCompress)
         {
             sal_uInt64 nFileSize(0);
 
@@ -726,17 +726,13 @@ namespace
 
                 // create a file entry for a new file. Offset is set to 0 to mark
                 // the entry as new file entry
-                // the compress flag decides if entries should be compressed when
-                // they get written to the target package
-                static bool bUseCompression(true);
-
                 maPackedFileEntryVector.push_back(
                     PackedFileEntry(
                         static_cast< sal_uInt32 >(nFileSize),
                         0,
                         nCrc32,
                         rFileCandidate,
-                        bUseCompression));
+                        bCompress));
 
                 mbChanged = true;
             }
@@ -837,14 +833,14 @@ namespace comphelper
         return OUString(maBase + "/." + maName + ".pack");
     }
 
-    bool BackupFileHelper::tryPush()
+    bool BackupFileHelper::tryPush(bool bCompress)
     {
         if (splitBaseURL() && baseFileExists())
         {
             PackedFile aPackedFile(getName());
             FileSharedPtr aBaseFile(new osl::File(mrBaseURL));
 
-            if (aPackedFile.tryPush(aBaseFile))
+            if (aPackedFile.tryPush(aBaseFile, bCompress))
             {
                 // reduce to allowed number and flush
                 aPackedFile.tryReduceToNumBackups(mnNumBackups);
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index 54d8b3c..f2841ef 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -614,8 +614,6 @@ Components::Components(
 
 Components::~Components()
 {
-    SAL_WARN("configmgr", "################# Components::~Components() #####################");
-
     // get flag if _exit was already called which is a sign to not to secure user config
     const bool bExitWasCalled(comphelper::BackupFileHelper::getExitWasCalled());
 
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 16274bc..addc8a0 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -569,11 +569,14 @@ void Desktop::Init()
             SetBootstrapError( BE_OFFICECONFIG_BROKEN, e.Message );
         }
 
+        // test code for ProfileSafeMode to allow testing the fail
+        // of loading the office configuration initially. To use,
+        // either set to true and compile, or set a breakpoint
+        // in debugger and change the local bool
         static bool bTryHardOfficeconfigBroken(false);
 
         if (bTryHardOfficeconfigBroken)
         {
-            SAL_WARN("configmgr", "################# Desktop::Init() #####################");
             SetBootstrapError(BE_OFFICECONFIG_BROKEN, OUString());
         }
     }
diff --git a/include/comphelper/backupfilehelper.hxx b/include/comphelper/backupfilehelper.hxx
index 2c6cc25..7cb2023 100644
--- a/include/comphelper/backupfilehelper.hxx
+++ b/include/comphelper/backupfilehelper.hxx
@@ -21,10 +21,23 @@ namespace comphelper
 {
     /** Helper class to backup/restore a single file
      *
+     *  This is a general class to manage backups/restore of the file
+     *  given by the URL. The container holding the backups is created
+     *  aside the original file, e.g for 'test.txt' a container
+     *  called '.test.pack' will be used. If it was not yet backed-up
+     *  this container file will be created at the 1st backup and deleted
+     *  when the last gets removed. The container holds a stack with a
+     *  maximum given number (in the constructor) of copies, these are by
+     *  default compressed, but don't have to be (see tryPush).
+     *
+     *  Due to being on a low system level here, no UNO API and not much
+     *  other tooling can be used, as a consequence for the container a
+     *  own simple format is used and e.g. the zip lib directly.
+     *
      *  You need to hand over the URL of the file to look at and
      *  a maximum number of allowed copies. That number is internally
-     *  limited to a max of 10 (see implementation). The number of
-     *  allowed copies is limited to [1..max].
+     *  limited to a absolute max of 10 (see implementation). The number
+     *  of allowed copies is limited to [1..max].
      *
      *  Calling tryPush() will check if there is no backup yet or if
      *  there is one that the file has changed. If yes, a new copy is
@@ -102,10 +115,14 @@ namespace comphelper
          *  Also may cleanup older backups when NumBackups given in the
          *  constructor has changed.
          *
+         *  @param  bCompress
+         *          Defines if the new backup will be compressed when
+         *          added. Default is true
+         *
          *  @return bool
          *          returns true if a new backup was actually created
          */
-        bool tryPush();
+        bool tryPush(bool bCompress = true);
 
         /** finds out if a restore is possible
          *


More information about the Libreoffice-commits mailing list