Skip to content

Commit

Permalink
don't merge if source extension directory is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
moldcraft committed Dec 22, 2014
1 parent 1c3cf58 commit e6d4f11
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions class-fw-extension-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,24 @@ private function merge_extensions($source_dir, $destination_dir)
$source_extension_dir = $source_dir .'/'. $ext_dir['name'];
$destination_extension_dir = $destination_dir .'/'. $ext_dir['name'];

{
$source_ext_files = $wp_filesystem->dirlist($source_extension_dir, true);
if ($source_ext_files === false) {
return new WP_Error($wp_error_id,
__('Cannot access directory: ', 'fw') . $source_extension_dir
);
}

if (empty($source_ext_files)) {
/**
* Source extension directory is empty, do nothing.
* This happens when the extension is a git submodule in repository
* but in zip it comes as an empty directory.
*/
continue;
}
}

// prepare destination
{
// create if not exists
Expand Down Expand Up @@ -590,13 +608,6 @@ private function merge_extensions($source_dir, $destination_dir)

// move files from source to destination extension directory
{
$source_ext_files = $wp_filesystem->dirlist($source_extension_dir, true);
if ($source_ext_files === false) {
return new WP_Error($wp_error_id,
__('Cannot access directory: ', 'fw') . $source_extension_dir
);
}

$source_has_extensions_dir = false;

foreach ($source_ext_files as $source_ext_file) {
Expand Down

0 comments on commit e6d4f11

Please sign in to comment.