Skip to content

Commit

Permalink
Dev: remove tmp files of update process
Browse files Browse the repository at this point in the history
  • Loading branch information
louis committed Aug 13, 2015
1 parent c09a8fa commit ba941f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions application/controllers/admin/update.php
Expand Up @@ -270,6 +270,9 @@ function step4()
// Should never bug (version.php is checked before))
$updateModel->updateVersion($destinationBuild);
$updateModel->destroyGlobalSettings();
$updateModel->removeTmpFile('update.zip');
$updateModel->removeTmpFile('comfort_updater_cookie.txt');

// TODO : aData should contains information about each step
return $this->controller->renderPartial('update/updater/steps/_final', array(), false, true);
}
Expand Down
22 changes: 22 additions & 0 deletions application/models/UpdateForm.php
Expand Up @@ -339,6 +339,28 @@ public function removeDeletedFiles($updateinfos)
return (object) $return;
}

/**
* Delete a tmp file
* @param string the name of the file to delete in tmp/ directory
* @return obj
*/
public function removeTmpFile($sTmpFile = 'update.zip')
{
$sTmpFilePath = $this->tempdir.DIRECTORY_SEPARATOR.$sTmpFile;
if ( file_exists( $sTmpFilePath ) )
{
if( ! @unlink( $sTmpFilePath ) )
{
$return = array('result'=>FALSE, 'error'=>'cant_remove_update_file', 'message'=>'file : '.$sTmpFilePath);
return (object) $return;
}
}

$return = array('result' => TRUE);
return (object) $return;
}


/**
* Update the version file to the destination build version
* @param INT $destinationBuild the id of the new version
Expand Down

0 comments on commit ba941f0

Please sign in to comment.