Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Prevent pathid and fileid collisions
Browse files Browse the repository at this point in the history
Makes sure we do not repeat the same ID in a tree instance
(that would defeat its purpose of being a unique identifier
and may cause problems for jstree).
  • Loading branch information
fbergkemper committed Aug 5, 2015
1 parent 61731aa commit e07d500
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions module/Restore/src/Restore/Controller/RestoreController.php
Expand Up @@ -109,8 +109,6 @@ public function indexAction()
}

return new ViewModel(array(
'restore_params' => $this->restore_params,
'form' => $form,
'result' => $result
));

Expand Down Expand Up @@ -196,7 +194,7 @@ private function buildSubtree()
else {
--$dnum;
$items .= '{';
$items .= '"id":"' . $dir['pathid'] . '"';
$items .= '"id":"-' . $dir['pathid'] . '"';
$items .= ',"text":"' . $dir["name"] . '"';
$items .= ',"icon":"glyphicon glyphicon-folder-close"';
$items .= ',"state":""';
Expand Down Expand Up @@ -390,7 +388,7 @@ private function getDirectories($jobid=null, $pathid=null)
$result = $director->send_command(".bvfs_lsdirs jobid=$jobid path=/", 2, $jobid);
}
else {
$result = $director->send_command(".bvfs_lsdirs jobid=$jobid pathid=$pathid", 2, $jobid);
$result = $director->send_command(".bvfs_lsdirs jobid=$jobid pathid=" . abs($pathid), 2, $jobid);
}
$directories = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $directories['result']['directories'];
Expand All @@ -409,7 +407,7 @@ private function getFiles($jobid=null, $pathid=null)
$result = $director->send_command(".bvfs_lsfiles jobid=$jobid path=/", 2);
}
else {
$result = $director->send_command(".bvfs_lsfiles jobid=$jobid pathid=$pathid", 2);
$result = $director->send_command(".bvfs_lsfiles jobid=$jobid pathid=" . abs($pathid), 2);
}
$files = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $files['result']['files'];
Expand Down
2 changes: 1 addition & 1 deletion module/Restore/view/restore/restore/index.phtml
Expand Up @@ -136,7 +136,7 @@ $this->headTitle($title);
checked_files.push(this.id);
}
else if(this.data.type == 'D') {
checked_directories.push(this.id);
checked_directories.push(Math.abs(this.id));
}
});

Expand Down

0 comments on commit e07d500

Please sign in to comment.