Permalink
Browse files

Make sure to deduplicate files selection

Fix Command __construct call.
  • Loading branch information...
1 parent 9e09d27 commit 65996d7c02818846b89c88a7e78035b1cae5e345 @cdujeu cdujeu committed May 26, 2016
@@ -81,7 +81,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
- $server = new CliServer();
+ $server = new CliServer("/");
$server->registerCatchAll();
$definitionsKeys = array_keys($this->getDefinition()->getOptions());
@@ -97,7 +97,7 @@ public function initFromNodes($nodes)
$this->files = array();
$this->inZip = false;
foreach ($nodes as $n) {
- $this->files[] = $n->getPath();
+ $this->addFile($n->getPath());
}
}
@@ -117,7 +117,7 @@ public function initFromArray($array)
if(strpos($v, "base64encoded:") === 0){
$v = base64_decode(array_pop(explode(':', $v, 2)));
}
- $this->files[] = Utils::decodeSecureMagic($v);
+ $this->addFile(Utils::decodeSecureMagic($v));
$this->isUnique = true;
//return ;
}
@@ -128,7 +128,7 @@ public function initFromArray($array)
if(strpos($v, "base64encoded:") === 0){
$v = base64_decode(array_pop(explode(':', $v, 2)));
}
- $this->files[] = Utils::decodeSecureMagic($v);
+ $this->addFile(Utils::decodeSecureMagic($v));
$index ++;
}
$this->isUnique = false;
@@ -145,13 +145,13 @@ public function initFromArray($array)
$p = Utils::decodeSecureMagic($p);
// First part must be the repository ID
$p = "/".implode("/", array_slice(explode("/", trim($p, "/")), 1));
- $this->files[] = $p;
+ $this->addFile($p);
}
}
if (isSet($array["nodes"]) && is_array($array["nodes"])) {
$this->files = array();
foreach($array["nodes"] as $value){
- $this->files[] = Utils::decodeSecureMagic($value);
+ $this->addFile(Utils::decodeSecureMagic($value));
}
$this->isUnique = count($this->files) == 1;
}
@@ -170,6 +170,13 @@ public function initFromArray($array)
}
}
}
+
+ public function addFile($filePath){
+ if(!in_array($filePath, $this->files)){
+ $this->files[] = $filePath;
+ }
+ }
+
/**
* Does the selection have one or more items
* @return bool
@@ -336,9 +343,5 @@ public function removeFile($file){
$this->nodes = $newNodes;
}
}
-
- public function addFile($file){
- $this->files[] = $file;
- }
-
+
}

0 comments on commit 65996d7

Please sign in to comment.