Skip to content

Commit

Permalink
Allow for definition of target filename (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: rvogel <[email protected]>
  • Loading branch information
osnard and rvogel authored Apr 3, 2024
1 parent 01c7954 commit a7e3182
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Commands/WikiBackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected function readInSettingsFile() {
$settings = $settingsReader->getSettingsFromDirectory( $this->mediawikiRoot );

$requiredFields = [
'dbname', 'dbpassword', 'dbuser', 'dbserver', 'wikiName'
'dbname', 'dbpassword', 'dbuser', 'dbserver'
];

foreach( $requiredFields as $requiredField ) {
Expand Down Expand Up @@ -218,7 +218,22 @@ protected function makeDestFilepath() {
$suffix = "-$timestamp";
}

return "{$this->dest}/{$this->wikiName}{$suffix}.zip";
$targetFilename = $this->getTargetFilename();

return "{$this->dest}/{$targetFilename}{$suffix}.zip";
}

private function getTargetFilename() {
$filename = 'mediawiki';
if ( !empty( $this->wikiName ) ) {
$filename = $this->wikiName;
}
$profileOptions = $this->profile->getOptions();
if ( isset( $profileOptions['target-filename'] ) && !empty( $profileOptions['target-filename'] ) {
$filename = $profileOptions['target-filename'];
}

return $filename;
}

protected function addImagesFolder() {
Expand Down
1 change: 1 addition & 0 deletions src/DefaultBackupProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DefaultBackupProfile implements IBackupProfile {
* @var array
*/
protected $data = [
'target-filename' => '',
'fs-options' => [
'include-custom-paths' => [
'extensions/SemanticMediaWiki/.smw.json'
Expand Down

0 comments on commit a7e3182

Please sign in to comment.