summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2010-11-25 16:30:04 +0000
committerMichael Meeks <michael.meeks@novell.com>2010-11-25 16:30:04 +0000
commitdd1ebc46c5487e76c81cc6dec17b20796e110e08 (patch)
treed7005679f318819783e139100af1ec19bae417ac
parent3583b0cab416295c2dd7d553eb7b5e6ee10d0101 (diff)
disable multiple migrations via MIGRATED stamp file
If we fail to auto-migrate, this can cause lots of pain - since people are unaware of where the migration occurs from. Thus - before we start migrating, we create a 'MIGRATED' stamp file in the source of that, and if this is present next migration, we simply don't migrate - fixed for Mechtilde.
-rw-r--r--desktop/source/migration/migration.cxx33
-rw-r--r--desktop/source/migration/migration_impl.hxx5
2 files changed, 29 insertions, 9 deletions
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index 2c1d6d69e0..e66d1269ea 100644
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -85,6 +85,7 @@ static const ::rtl::OUString ITEM_DESCRIPTOR_LABEL(RTL_CONSTASCII_USTRINGPARAM("
static const ::rtl::OUString MENU_SEPERATOR(RTL_CONSTASCII_USTRINGPARAM(" | "));
static const ::rtl::OUString MENU_SUBMENU(RTL_CONSTASCII_USTRINGPARAM("..."));
+static const ::rtl::OUString MIGRATION_STAMP_NAME(RTL_CONSTASCII_USTRINGPARAM("/MIGRATED"));
::rtl::OUString retrieveLabelFromCommand(const ::rtl::OUString& sCommand, const ::rtl::OUString& sModuleIdentifier)
{
@@ -194,15 +195,31 @@ static const ::rtl::OUString MENU_SUBMENU(RTL_CONSTASCII_USTRINGPARAM("..."));
return sIdentifier;
}
-sal_Bool MigrationImpl::initializeMigration()
+bool MigrationImpl::alreadyMigrated()
{
- sal_Bool bRet = sal_False;
+ rtl::OUString aStr = m_aInfo.userdata + MIGRATION_STAMP_NAME;
+ File aFile(aStr);
+ // create migration stamp, and/or check its existence
+ bool bRet = aFile.open (osl_File_OpenFlag_Write | osl_File_OpenFlag_Create | osl_File_OpenFlag_NoLock) == FileBase::E_EXIST;
+ OSL_TRACE( "File '%s' exists? %d\n",
+ rtl::OUStringToOString(aStr, RTL_TEXTENCODING_ASCII_US).getStr(),
+ bRet );
+ return bRet;
+}
+
+bool MigrationImpl::initializeMigration()
+{
+ bool bRet = false;
if (!checkMigrationCompleted()) {
readAvailableMigrations(m_vMigrationsAvailable);
sal_Int32 nIndex = findPreferedMigrationProcess(m_vMigrationsAvailable);
- if ( nIndex >= 0 )
+ // m_aInfo is now set to the preferred migration source
+ if ( nIndex >= 0 ) {
+ if (alreadyMigrated())
+ return false;
m_vrMigrations = readMigrationSteps(m_vMigrationsAvailable[nIndex].name);
+ }
bRet = m_aInfo.userdata.getLength() > 0;
}
@@ -358,7 +375,7 @@ void MigrationImpl::setMigrationCompleted()
}
}
-sal_Bool MigrationImpl::checkMigrationCompleted()
+bool MigrationImpl::checkMigrationCompleted()
{
sal_Bool bMigrationCompleted = sal_False;
try {
@@ -367,15 +384,17 @@ sal_Bool MigrationImpl::checkMigrationCompleted()
aPropertySet->getPropertyValue(
OUString(RTL_CONSTASCII_USTRINGPARAM("MigrationCompleted"))) >>= bMigrationCompleted;
- static const char* pEnv = getenv("SAL_DISABLE_USERMIGRATION" );
- if( !bMigrationCompleted && pEnv != NULL )
+ if( !bMigrationCompleted && getenv("SAL_DISABLE_USERMIGRATION" ) )
{
// migration prevented - fake it's success
setMigrationCompleted();
+ bMigrationCompleted = sal_True;
}
} catch (Exception&) {
// just return false...
}
+ OSL_TRACE( "Migration %s", bMigrationCompleted ? "already completed" : "not done" );
+
return bMigrationCompleted;
}
@@ -1210,7 +1229,7 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat
for (; i<nCount; ++i)
{
::rtl::OUString sCmd;
- uno::Sequence< beans::PropertyValue > aTempPropSeq;
+ uno::Sequence< beans::PropertyValue > aTempPropSeq;
xTemp->getByIndex(i) >>= aTempPropSeq;
for (sal_Int32 j=0; j<aTempPropSeq.getLength(); ++j)
{
diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx
index 835194f32e..d66cabad94 100644
--- a/desktop/source/migration/migration_impl.hxx
+++ b/desktop/source/migration/migration_impl.hxx
@@ -207,6 +207,7 @@ private:
// functions to control the migration process
bool readAvailableMigrations(migrations_available&);
+ bool alreadyMigrated();
migrations_vr readMigrationSteps(const ::rtl::OUString& rMigrationName);
sal_Int32 findPreferedMigrationProcess(const migrations_available&);
install_info findInstallation(const strings_v& rVersions);
@@ -235,12 +236,12 @@ private:
void refresh();
void setMigrationCompleted();
- sal_Bool checkMigrationCompleted();
+ bool checkMigrationCompleted();
public:
MigrationImpl(const NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory >&);
~MigrationImpl();
- sal_Bool initializeMigration();
+ bool initializeMigration();
sal_Bool doMigration();
rtl::OUString getOldVersionName();
};