Show cli notice for big installations

This commit is contained in:
Victor Dubiniuk 2016-03-25 13:22:22 +03:00
parent b05269826a
commit 118c39d472
2 changed files with 53 additions and 29 deletions

View File

@ -45,6 +45,7 @@ class ReleaseNotes {
*/
public function getReleaseNotes($fromVersion, $toVersion){
$releaseNotes = [];
$l10n = \OC::$server->getL10N('core');
try {
$fromVersionMajorMinor = $this->getMajorMinor($fromVersion);
@ -59,20 +60,28 @@ class ReleaseNotes {
}
if ( $fromVersionMajorMinor === '8.2' && $toVersionMajorMinor === '9.0' ) {
// MySQL only
if ($this->isMysql()) {
if ($this->countFilecacheEntries() > 200000) {
$message = \OC::$server->getL10N('core')->t(
"You have an ownCloud installation with over 200.000 files so the upgrade might take a while. Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE %s ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions;",
if (!$this->isCliMode() && $this->countFilecacheEntries() > 200000) {
$releaseNotes[] = $l10n->t(
"You have an ownCloud installation with over 200.000 files so the upgrade might take a while. The recommendation is to use the command-line instead of the web interface for big ownCloud servers."
);
}
if ($this->isMysql() && $this->countFilecacheEntries() > 200000) {
$releaseNotes[] = $l10n->t(
"Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE %s ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions;",
[$this->dbConnection->getPrefix().'filecache']
);
$releaseNotes[] = $message;
}
}
}
return $releaseNotes;
}
/**
* @return bool
*/
protected function isCliMode(){
return \OC::$CLI;
}
/**
* @return bool
*/

View File

@ -32,24 +32,31 @@ class Test_ReleaseNotes extends \Test\TestCase {
}
public function resultProvider82to90(){
return [
[ [], false, 20 ],
[ [], false, 1000000 ],
[ [], true, 20 ],
[ [
\OC::$server->getL10N('core')->t(
"You have an ownCloud installation with over 200.000 files so the upgrade might take a while. Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE %s ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions;",
$l10n = \OC::$server->getL10N('core');
$alterTableMessage = $l10n->t(
"Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE %s ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions;",
['ocx_filecache']
)
], true, 1000000 ],
);
$useCliMessage = $l10n->t(
"You have an ownCloud installation with over 200.000 files so the upgrade might take a while. The recommendation is to use the command-line instead of the web interface for big ownCloud servers."
);
return [
[ [], false, false, 20 ],
[ [], false, true, 20 ],
[ [], true, false, 20 ],
[ [], true, true, 20 ],
[ [ $useCliMessage ], false, false, 1000000 ],
[ [], false, true, 1000000 ],
[ [ $useCliMessage, $alterTableMessage ], true, false, 1000000 ],
[ [ $alterTableMessage ], true, true, 1000000 ],
];
}
/**
* @dataProvider resultProvider82to90
*/
public function test82to90($expected, $isMysql, $fileCount){
$releaseNotesMock = $this->getReleaseNotesMock($isMysql, $fileCount);
public function test82to90($expected, $isMysql, $isCliMode, $fileCount){
$releaseNotesMock = $this->getReleaseNotesMock($isMysql, $isCliMode, $fileCount);
$actual = $releaseNotesMock->getReleaseNotes('8.2.22', '9.0.1');
$this->assertEquals($expected, $actual);
}
@ -58,24 +65,28 @@ class Test_ReleaseNotes extends \Test\TestCase {
public function resultProvider90to91(){
return [
[ [], false, 20 ],
[ [], false, 1000000 ],
[ [], true, 20 ],
[ [], true, 1000000 ],
[ [], false, false, 20 ],
[ [], false, true, 20 ],
[ [], true, false, 20 ],
[ [], true, true, 20 ],
[ [], false, false, 1000000 ],
[ [], false, true, 1000000 ],
[ [], true, false, 1000000 ],
[ [], true, true, 1000000 ],
];
}
/**
* @dataProvider resultProvider90to91
*/
public function test90to91($expected, $isMysql, $fileCount){
$releaseNotesMock = $this->getReleaseNotesMock($isMysql, $fileCount);
public function test90to91($expected, $isMysql, $isCliMode, $fileCount){
$releaseNotesMock = $this->getReleaseNotesMock($isMysql, $isCliMode, $fileCount);
$actual = $releaseNotesMock->getReleaseNotes('9.0.1', '9.1.0');
$this->assertEquals($expected, $actual);
}
private function getReleaseNotesMock($isMysql, $fileCount){
private function getReleaseNotesMock($isMysql, $isCliMode, $fileCount){
$dbConnectionMock = $this->getMockBuilder('OCP\IDBConnection')
->setMethods(array_merge($this->getMethods('OCP\IDBConnection'), ['getPrefix']))
->getMock()
@ -86,7 +97,7 @@ class Test_ReleaseNotes extends \Test\TestCase {
;
$releaseNotesMock = $this->getMockBuilder('OC\ReleaseNotes')
->setConstructorArgs([$dbConnectionMock])
->setMethods(['isMysql', 'countFilecacheEntries'])
->setMethods(['isMysql', 'isCliMode', 'countFilecacheEntries'])
->getMock()
;
@ -94,6 +105,10 @@ class Test_ReleaseNotes extends \Test\TestCase {
->method('isMysql')
->willReturn($isMysql)
;
$releaseNotesMock->expects($this->any())
->method('isCliMode')
->willReturn($isCliMode)
;
$releaseNotesMock->expects($this->any())
->method('countFilecacheEntries')
->willReturn($fileCount)