diff options
author | Michael Meeks <michael.meeks@suse.com> | 2011-11-16 16:59:39 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2011-11-16 17:04:54 +0000 |
commit | 042247b3e428cb7352c06a670576819c67378090 (patch) | |
tree | 7faec906f90ec86a67a1bdf925ca6b6490086f4f /desktop | |
parent | 6beeefab7698e86eb7864196a35c232ff84625fa (diff) |
Fixup legacy sleepycat db database usage for packages
Previously empty legacy registered_packages.db databases were created
unconditionally, at some efficiency and startup cost, despite these
being deprectated since before version 3.2.
We now handle version mismatches by warning on the console and ignoring
these files.
Diffstat (limited to 'desktop')
6 files changed, 38 insertions, 38 deletions
diff --git a/desktop/source/deployment/dp_persmap.cxx b/desktop/source/deployment/dp_persmap.cxx index 92e4080063f9..c09bb9b9d5d8 100644 --- a/desktop/source/deployment/dp_persmap.cxx +++ b/desktop/source/deployment/dp_persmap.cxx @@ -79,35 +79,20 @@ PersistentMap::~PersistentMap() } //______________________________________________________________________________ -PersistentMap::PersistentMap( OUString const & url_, bool readOnly ) +PersistentMap::PersistentMap( OUString const & url ) : m_db( 0, 0 ) { try { - OUString url( expandUnoRcUrl(url_) ); - if ( File::getSystemPathFromFileURL( url, m_sysPath ) != File::E_None ) - { + rtl::OUString fileURL = expandUnoRcUrl(url); + if ( File::getSystemPathFromFileURL( fileURL, m_sysPath ) != File::E_None ) OSL_ASSERT( false ); - } + OString cstr_sysPath( OUStringToOString( m_sysPath, RTL_TEXTENCODING_UTF8 ) ); - char const * pcstr_sysPath = cstr_sysPath.getStr(); - - u_int32_t flags = DB_CREATE; - if (readOnly) { - flags = DB_RDONLY; - if (! create_ucb_content( - 0, url, - Reference<com::sun::star::ucb::XCommandEnvironment>(), - false /* no throw */ )) { - // ignore non-existent file in read-only mode: simulate empty db - pcstr_sysPath = 0; - flags = DB_CREATE; - } - } - int err = m_db.open( // xxx todo: DB_THREAD, DB_DBT_MALLOC currently not used - 0, pcstr_sysPath, 0, DB_HASH, flags/* | DB_THREAD*/, 0664 /* fs mode */ ); + 0, cstr_sysPath.getStr(), 0, DB_HASH, + DB_CREATE/* | DB_THREAD*/, 0664 /* fs mode */ ); if (err != 0) throw_rtexc(err); } diff --git a/desktop/source/deployment/inc/dp_persmap.h b/desktop/source/deployment/inc/dp_persmap.h index c078cf902ec5..a81cef5685c1 100644 --- a/desktop/source/deployment/inc/dp_persmap.h +++ b/desktop/source/deployment/inc/dp_persmap.h @@ -41,7 +41,8 @@ namespace dp_misc typedef ::boost::unordered_map< ::rtl::OString, ::rtl::OString, ::rtl::OStringHash > t_string2string_map; -//============================================================================== +// Class to read obsolete registered extensions +// should be removed for LibreOffice 4.0 class PersistentMap { ::rtl::OUString m_sysPath; @@ -50,7 +51,7 @@ class PersistentMap public: ~PersistentMap(); - PersistentMap( ::rtl::OUString const & url, bool readOnly ); + PersistentMap( ::rtl::OUString const & url ); /** in mem db */ PersistentMap(); diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx index f220aaf40daa..47cc72fcabbf 100644 --- a/desktop/source/deployment/manager/dp_activepackages.cxx +++ b/desktop/source/deployment/manager/dp_activepackages.cxx @@ -127,8 +127,7 @@ namespace dp_manager { ActivePackages::ActivePackages() {} -ActivePackages::ActivePackages(::rtl::OUString const & url, bool readOnly): - m_map(url, readOnly) {} +ActivePackages::ActivePackages(::rtl::OUString const & url) : m_map(url) {} ActivePackages::~ActivePackages() {} diff --git a/desktop/source/deployment/manager/dp_activepackages.hxx b/desktop/source/deployment/manager/dp_activepackages.hxx index 2a4d18686346..61057bc9533e 100644 --- a/desktop/source/deployment/manager/dp_activepackages.hxx +++ b/desktop/source/deployment/manager/dp_activepackages.hxx @@ -71,7 +71,7 @@ public: ActivePackages(); - ActivePackages(::rtl::OUString const & url, bool readOnly); + ActivePackages(::rtl::OUString const & url); ~ActivePackages(); diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 680dbf855d9d..0e88d1f2efde 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -198,8 +198,7 @@ void PackageManagerImpl::initActivationLayer( dbName = m_registrationData_expanded + OUSTR("/extensions.db"); } //The data base can always be written because it it always in the user installation - m_activePackagesDB.reset( - new ActivePackages( dbName, false ) ); + m_activePackagesDB.reset( new ActivePackages( dbName ) ); if (! m_readOnly && ! m_context.equals(OUSTR("bundled"))) { diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index f0a113bf4cb1..83ecba912513 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -43,6 +43,7 @@ #include "osl/file.hxx" #include "cppuhelper/exc_hlp.hxx" #include "ucbhelper/content.hxx" +#include "unotools/ucbhelper.hxx" #include "comphelper/anytostring.hxx" #include "comphelper/servicedecl.hxx" #include "xmlscript/xml_helper.hxx" @@ -120,8 +121,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); + // for backwards compatibility - nil if no (compatible) back-compat db present ::std::auto_ptr<PersistentMap> m_registeredPackages; - // for backwards compatibility virtual void SAL_CALL disposing(); @@ -209,7 +210,7 @@ BackendImpl::BackendImpl( if (transientMode()) { - //TODO + // TODO } else { @@ -224,12 +225,23 @@ BackendImpl::BackendImpl( ::std::list<OUString> folders = m_backendDb->getAllDataUrls(); deleteUnusedFolders(OUString(), folders); - configmgrini_verify_init( xCmdEnv ); - m_registeredPackages.reset( - new PersistentMap( - makeURL( getCachePath(), OUSTR("registered_packages.db") ), - false ) ); + ::std::auto_ptr<PersistentMap> pMap; + rtl::OUString aCompatURL( makeURL( getCachePath(), OUSTR("registered_packages.db") ) ); + + // Don't create it if it doesn't exist already + if ( ::utl::UCBContentHelper::Exists( expandUnoRcUrl( aCompatURL ) ) ) + { + try { + pMap = ::std::auto_ptr<PersistentMap>( new PersistentMap( aCompatURL ) ); + } catch (Exception &e) { // const uno::RunTimeException &e) { + rtl::OStringBuffer aStr( "Exception loading legacy package database: '" ); + aStr.append( rtl::OUStringToOString( e.Message, osl_getThreadTextEncoding() ) ); + aStr.append( "' - ignoring file, please remove it.\n" ); + dp_misc::writeConsole( aStr.getStr() ); + } + } + m_registeredPackages = pMap; } } @@ -549,10 +561,12 @@ BackendImpl::PackageImpl::isRegistered_( bool bReg = false; if (that->hasActiveEntry(getURL())) bReg = true; - if (!bReg) - //fallback for user extension registered in berkeley DB + if (!bReg && that->m_registeredPackages.get()) + { + // fallback for user extension registered in berkeley DB bReg = that->m_registeredPackages->has( rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 )); + } return beans::Optional< beans::Ambiguous<sal_Bool> >( true, beans::Ambiguous<sal_Bool>( bReg, false ) ); @@ -735,7 +749,9 @@ void BackendImpl::PackageImpl::processPackage_( } else // revoke { - if (!that->removeFromConfigmgrIni(m_isSchema, url, xCmdEnv)) { + if (!that->removeFromConfigmgrIni(m_isSchema, url, xCmdEnv) && + that->m_registeredPackages.get()) { + // Obsolete package database handling - should be removed for LibreOffice 4.0 t_string2string_map entries( that->m_registeredPackages->getEntries()); for (t_string2string_map::iterator i(entries.begin()); |