-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[stable9] Add repair step and revert "Open updater" button #1501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7a135d8
Revert "Show an update button instead of the updater"
MorrisJobke 8c13345
Revert "Fix tests"
MorrisJobke 2fb10ce
Add repair step to remove .step file after update
MorrisJobke 91757e7
Revert "[stable9] Don't show the updater if updater is incompatible"
MorrisJobke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?php | ||
| /** | ||
| * @copyright Copyright (c) 2016 Morris Jobke <[email protected]> | ||
| * | ||
| * @author Morris Jobke <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Repair; | ||
|
|
||
| use OC\Hooks\BasicEmitter; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\IRepairStep; | ||
|
|
||
| class MoveUpdaterStepFile extends BasicEmitter implements \OC\RepairStep { | ||
|
|
||
| /** @var \OCP\IConfig */ | ||
| protected $config; | ||
|
|
||
| /** | ||
| * @param \OCP\IConfig $config | ||
| */ | ||
| public function __construct($config) { | ||
| $this->config = $config; | ||
| } | ||
|
|
||
| public function getName() { | ||
| return 'Move .step file of updater to backup location'; | ||
| } | ||
|
|
||
| public function run() { | ||
|
|
||
| $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT); | ||
| $instanceId = $this->config->getSystemValue('instanceid', null); | ||
|
|
||
| if(!is_string($instanceId) || empty($instanceId)) { | ||
| return; | ||
| } | ||
|
|
||
| $updaterFolderPath = $dataDir . '/updater-' . $instanceId; | ||
| $stepFile = $updaterFolderPath . '/.step'; | ||
| if(file_exists($stepFile)) { | ||
| $this->emit('\OC\Repair', 'info', array('.step file exists')); | ||
|
|
||
| $previousStepFile = $updaterFolderPath . '/.step-previous-update'; | ||
|
|
||
| // cleanup | ||
| if(file_exists($previousStepFile)) { | ||
| if(\OC_Helper::rmdirr($previousStepFile)) { | ||
| $this->emit('\OC\Repair', 'info', array('.step-previous-update removed')); | ||
| } else { | ||
| $this->emit('\OC\Repair', 'info', array('.step-previous-update can\'t be removed - abort move of .step file')); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| // move step file | ||
| if(rename($stepFile, $previousStepFile)) { | ||
| $this->emit('\OC\Repair', 'info', array('.step file moved to .step-previous-update')); | ||
| } else { | ||
| $this->emit('\OC\Repair', 'warning', array('.step file can\'t be moved')); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we remove that as well now? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment on master only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. This is also not on master. (no idea how this came in here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha ... it was only added in stable9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this.