Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/owncloud/updater into ux-2
Browse files Browse the repository at this point in the history
  • Loading branch information
te-online committed Dec 23, 2014
2 parents 67077be + 48811d9 commit aaaae3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ public static function getSources($version) {
);
}

public static function addDirectoryToZip($zip, $dir, $base) {
$newFolder = str_replace($base, '', $dir);
$zip->addEmptyDir($newFolder);
foreach(glob($dir . '/*') as $file) {
if(is_dir($file)) {
$zip = self::addDirectoryToZip($zip, $file, $base);
public static function addDirectoryToZip($zip, $dir) {
$dirIterator = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $key=>$file) {
$relPath = str_replace($dir, '', $key);
if ($file->isDir()){
$zip->addEmptyDir($relPath);
} else {
$newFile = str_replace($base, '', $file);
$zip->addFile($file, $newFile);
$zip->addFile(realpath($key), $relPath);
}
}
return $zip;
Expand Down
2 changes: 1 addition & 1 deletion lib/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function update($version, $backupBase){
// zip backup
$zip = new \ZipArchive();
if ($zip->open($backupBase . ".zip", \ZIPARCHIVE::CREATE) === true){
Helper::addDirectoryToZip($zip, $backupBase, $backupBase);
Helper::addDirectoryToZip($zip, $backupBase);
$zip->close();
\OCP\Files::rmdirr($backupBase);
}
Expand Down

0 comments on commit aaaae3c

Please sign in to comment.