Skip to content

Commit

Permalink
MDL-49008 lang: removed preemptive deleting of old language files
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjdavis committed Feb 22, 2015
1 parent 1ab376e commit bbc7df8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
27 changes: 0 additions & 27 deletions admin/tool/langimport/classes/controller.php
Expand Up @@ -175,33 +175,6 @@ public function update_all_installed_languages() {
}
}

// Clean-up currently installed versions of the packs.
foreach ($neededlangs as $packindex => $pack) {
if ($pack == 'en') {
continue;
}

// Delete old directories.
$dest1 = $CFG->dataroot.'/lang/'.$pack;
$dest2 = $CFG->dirroot.'/lang/'.$pack;
if (file_exists($dest1)) {
if (!remove_dir($dest1)) {
$this->errors[] = 'Could not delete old directory '.$dest1.', update of '.$pack
.' failed, please check permissions.';
unset($neededlangs[$packindex]);
continue;
}
}
if (file_exists($dest2)) {
if (!remove_dir($dest2)) {
$this->errors[] = 'Could not delete old directory '.$dest2.', update of '.$pack
.' failed, please check permissions.';
unset($neededlangs[$packindex]);
continue;
}
}
}

try {
$updated = $this->install_languagepacks($neededlangs, true);
} catch (\moodle_exception $e) {
Expand Down
10 changes: 8 additions & 2 deletions lib/componentlib.class.php
Expand Up @@ -323,8 +323,14 @@ function install() {
/// Move current revision to a safe place
$destinationdir = $CFG->dataroot.'/'.$this->destpath;
$destinationcomponent = $destinationdir.'/'.$this->componentname;
@remove_dir($destinationcomponent.'_old'); //Deleting possible old components before
@rename ($destinationcomponent, $destinationcomponent.'_old'); //Moving to a safe place
@remove_dir($destinationcomponent.'_old'); // Deleting a possible old version.

// Moving to a safe place.
$moveresult = rename($destinationcomponent, $destinationcomponent.'_old');
if (!$moveresult) {
debugging("Failed to rename {$destinationcomponent} to {$destinationcomponent}_old while installing a language");
}

/// Unzip new version
if (!unzip_file($zipfile, $destinationdir, false)) {
/// Error so, go back to the older
Expand Down

0 comments on commit bbc7df8

Please sign in to comment.