Kaydet (Commit) 0b4ba827 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Remove hack for LO 3.6.x downgrading to preregistered bundled extensions again

With LO 4 using its own user profile, the problem of sharing a user profile
between LO versions that do and do not use preregistration of bundled extensions
can no longer happen, and so e9631f40
"fdo#53006: And detect LO downgrading scenarios..." can be reverted again.

Change-Id: I515077340823b8b277ffb6758b0d6a3cf8bfd0d5
üst 9802c450
...@@ -214,19 +214,6 @@ void removeTree(OUString const & url) { ...@@ -214,19 +214,6 @@ void removeTree(OUString const & url) {
// to old junk. Later on in Desktop::SynchronizeExtensionRepositories, the // to old junk. Later on in Desktop::SynchronizeExtensionRepositories, the
// removed cache data is recreated. // removed cache data is recreated.
// //
// As a special case, if you create a UserInstallation with LO >= 3.6.1, then
// run an old LO <= 3.5.x using share/prereg/bundled on the same
// UserInstallation (so that it partially overwrites user/extensions/bundled,
// potentially duplicating component information, but not touching
// user/extensions/bundled/buildid), and then run the new LO >= 3.6.1 on the
// same UserInstallation again, it can fail to start (due to the duplicated
// component information). Even though such downgrading scenarios at best work
// by luck in general, the special token LIBO_NON_PREREG_BUNDLED_EXTENSIONS=TRUE
// is used to detect and fix that problem: The assumption is that if an old LO
// <= 3.5.x messed with user/extensions/bundled in the meantime, then it would
// have rewritten the unorc (dropping the token), and LO >= 3.6.1 can detect
// that.
//
// Multiple instances of soffice.bin can execute this code in parallel for a // Multiple instances of soffice.bin can execute this code in parallel for a
// single UserInstallation, as it is called before OfficeIPCThread is set up. // single UserInstallation, as it is called before OfficeIPCThread is set up.
// Therefore, any errors here only lead to SAL_WARNs. // Therefore, any errors here only lead to SAL_WARNs.
...@@ -243,59 +230,47 @@ bool cleanExtensionCache() { ...@@ -243,59 +230,47 @@ bool cleanExtensionCache() {
rtl::Bootstrap::expandMacros(extDir); //TODO: detect failure rtl::Bootstrap::expandMacros(extDir); //TODO: detect failure
OUString bundledDir = extDir + "/bundled"; OUString bundledDir = extDir + "/bundled";
OUString buildIdFile(bundledDir + "/buildid"); OUString buildIdFile(bundledDir + "/buildid");
OUString bundledRcFile( osl::File fr(buildIdFile);
"$BUNDLED_EXTENSIONS_USER/registry/" osl::FileBase::RC rc = fr.open(osl_File_OpenFlag_Read);
"com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); switch (rc) {
rtl::Bootstrap::expandMacros(bundledRcFile); //TODO: detect failure case osl::FileBase::E_None:
rtl::Bootstrap bundledRc(bundledRcFile); {
OUString nonPrereg; rtl::ByteSequence s1;
if (bundledRc.getHandle() == 0 rc = fr.readLine(s1);
|| (bundledRc.getFrom("LIBO_NON_PREREG_BUNDLED_EXTENSIONS", nonPrereg) osl::FileBase::RC rc2 = fr.close();
&& nonPrereg == "TRUE")) SAL_WARN_IF(
{ rc2 != osl::FileBase::E_None, "desktop",
osl::File f(buildIdFile); "cannot close " << buildIdFile << " after reading: " << +rc2);
osl::FileBase::RC rc = f.open(osl_File_OpenFlag_Read); if (rc != osl::FileBase::E_None) {
switch (rc) { SAL_WARN(
case osl::FileBase::E_None: "desktop",
{ "cannot read from " << buildIdFile << ": " << +rc);
rtl::ByteSequence s1;
rc = f.readLine(s1);
osl::FileBase::RC rc2 = f.close();
SAL_WARN_IF(
rc2 != osl::FileBase::E_None, "desktop",
"cannot close " << buildIdFile << " after reading: "
<< +rc2);
if (rc != osl::FileBase::E_None) {
SAL_WARN(
"desktop",
"cannot read from " << buildIdFile << ": " << +rc);
break;
}
OUString s2(
reinterpret_cast< char const * >(s1.getConstArray()),
s1.getLength(), RTL_TEXTENCODING_ISO_8859_1);
// using ISO 8859-1 avoids any and all conversion errors;
// the content should only be a subset of ASCII, anyway
if (s2 == buildId) {
return false;
}
break; break;
} }
case osl::FileBase::E_NOENT: OUString s2(
break; reinterpret_cast< char const * >(s1.getConstArray()),
default: s1.getLength(), RTL_TEXTENCODING_ISO_8859_1);
SAL_WARN( // using ISO 8859-1 avoids any and all conversion errors; the
"desktop", // content should only be a subset of ASCII, anyway
"cannot open " << buildIdFile << " for reading: " << +rc); if (s2 == buildId) {
return false;
}
break; break;
} }
case osl::FileBase::E_NOENT:
break;
default:
SAL_WARN(
"desktop",
"cannot open " << buildIdFile << " for reading: " << +rc);
break;
} }
removeTree(extDir); removeTree(extDir);
OUString userRcFile( OUString userRcFile(
"$UNO_USER_PACKAGES_CACHE/registry/" "$UNO_USER_PACKAGES_CACHE/registry/"
"com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); "com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc");
rtl::Bootstrap::expandMacros(userRcFile); //TODO: detect failure rtl::Bootstrap::expandMacros(userRcFile); //TODO: detect failure
osl::FileBase::RC rc = osl::File::remove(userRcFile); rc = osl::File::remove(userRcFile);
SAL_WARN_IF( SAL_WARN_IF(
rc != osl::FileBase::E_None && rc != osl::FileBase::E_NOENT, "desktop", rc != osl::FileBase::E_None && rc != osl::FileBase::E_NOENT, "desktop",
"cannot remove file " << userRcFile << ": " << +rc); "cannot remove file " << userRcFile << ": " << +rc);
...@@ -303,8 +278,8 @@ bool cleanExtensionCache() { ...@@ -303,8 +278,8 @@ bool cleanExtensionCache() {
SAL_WARN_IF( SAL_WARN_IF(
rc != osl::FileBase::E_None && rc != osl::FileBase::E_EXIST, "desktop", rc != osl::FileBase::E_None && rc != osl::FileBase::E_EXIST, "desktop",
"cannot create path " << bundledDir << ": " << +rc); "cannot create path " << bundledDir << ": " << +rc);
osl::File f(buildIdFile); osl::File fw(buildIdFile);
rc = f.open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create); rc = fw.open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create);
if (rc != osl::FileBase::E_None) { if (rc != osl::FileBase::E_None) {
SAL_WARN( SAL_WARN(
"desktop", "desktop",
...@@ -316,13 +291,13 @@ bool cleanExtensionCache() { ...@@ -316,13 +291,13 @@ bool cleanExtensionCache() {
// containing single surrogate halves should never happen, anyway); the // containing single surrogate halves should never happen, anyway); the
// content should only be a subset of ASCII, anyway // content should only be a subset of ASCII, anyway
sal_uInt64 n = 0; sal_uInt64 n = 0;
rc = f.write(buf.getStr(), buf.getLength(), n); rc = fw.write(buf.getStr(), buf.getLength(), n);
SAL_WARN_IF( SAL_WARN_IF(
(rc != osl::FileBase::E_None (rc != osl::FileBase::E_None
|| n != static_cast< sal_uInt32 >(buf.getLength())), || n != static_cast< sal_uInt32 >(buf.getLength())),
"desktop", "desktop",
"cannot write to " << buildIdFile << ": " << +rc << ", " << n); "cannot write to " << buildIdFile << ": " << +rc << ", " << n);
rc = f.close(); rc = fw.close();
SAL_WARN_IF( SAL_WARN_IF(
rc != osl::FileBase::E_None, "desktop", rc != osl::FileBase::E_None, "desktop",
"cannot close " << buildIdFile << " after writing: " << +rc); "cannot close " << buildIdFile << " after writing: " << +rc);
......
...@@ -1009,13 +1009,6 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv ) ...@@ -1009,13 +1009,6 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
buf.append(LF); buf.append(LF);
} }
// See refreshBundledExtensionsDir (desktop/source/app/app.cxx):
if (m_eContext == CONTEXT_BUNDLED)
{
buf.append("LIBO_NON_PREREG_BUNDLED_EXTENSIONS=TRUE");
buf.append(LF);
}
// write unorc: // write unorc:
const Reference<io::XInputStream> xData( const Reference<io::XInputStream> xData(
::xmlscript::createInputStream( ::xmlscript::createInputStream(
......
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