Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 23fbb12

Browse files
author
Julien Jomier
committed
BUG: revert back to using the standard recursive calls
1 parent bf47280 commit 23fbb12

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

application/controllers/ImportController.php

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ private function _recursiveParseDirectory($path,$currentdir)
8080
{
8181
set_time_limit(0); // No time limit since import can take a long time
8282

83-
// We store the children in an array
84-
$childdirectories = array();
85-
8683
$it = new DirectoryIterator($path);
8784
foreach($it as $fileInfo)
8885
{
@@ -109,7 +106,20 @@ private function _recursiveParseDirectory($path,$currentdir)
109106
continue;
110107
}
111108

112-
$childdirectories[] = $fileInfo->getPathName();
109+
// Find if the child exists
110+
$child = $this->Folder->getFolderByName($currentdir,$fileInfo->getFilename());
111+
if(!$child)
112+
{
113+
$child = new FolderDao;
114+
$child->setName($fileInfo->getFilename());
115+
$child->setParentId($currentdir->getFolderId());
116+
$child->setDate(date('c'));
117+
$this->Folder->save($child);
118+
$this->Folderpolicyuser->createPolicy($this->userSession->Dao,$child,MIDAS_POLICY_ADMIN);
119+
$anonymousGroup=$this->Group->load(MIDAS_GROUP_ANONYMOUS_KEY);
120+
$this->Folderpolicygroup->createPolicy($anonymousGroup,$child,MIDAS_POLICY_READ);
121+
}
122+
$this->_recursiveParseDirectory($fileInfo->getPathName(),$child);
113123
}
114124
else // we have a file
115125
{
@@ -181,27 +191,7 @@ private function _recursiveParseDirectory($path,$currentdir)
181191
} // end isFile
182192
} // end foreach files/dirs in the directory
183193

184-
unset($it);
185-
186-
// Loop through the children directories
187-
foreach($childdirectories as $childdirectory)
188-
{
189-
// Find if the child exists
190-
$child = $this->Folder->getFolderByName($currentdir,$fileInfo->getFilename());
191-
if(!$child)
192-
{
193-
$child = new FolderDao;
194-
$child->setName($fileInfo->getFilename());
195-
$child->setParentId($currentdir->getFolderId());
196-
$child->setDate(date('c'));
197-
$this->Folder->save($child);
198-
$this->Folderpolicyuser->createPolicy($this->userSession->Dao,$child,MIDAS_POLICY_ADMIN);
199-
$anonymousGroup=$this->Group->load(MIDAS_GROUP_ANONYMOUS_KEY);
200-
$this->Folderpolicygroup->createPolicy($anonymousGroup,$child,MIDAS_POLICY_READ);
201-
}
202-
$this->_recursiveParseDirectory($childdirectory,$child);
203-
}
204-
194+
unset($it);
205195
return true;
206196
} // end _recursiveParseDirectory
207197

0 commit comments

Comments
 (0)