@@ -80,9 +80,6 @@ private function _recursiveParseDirectory($path,$currentdir)
80
80
{
81
81
set_time_limit (0 ); // No time limit since import can take a long time
82
82
83
- // We store the children in an array
84
- $ childdirectories = array ();
85
-
86
83
$ it = new DirectoryIterator ($ path );
87
84
foreach ($ it as $ fileInfo )
88
85
{
@@ -109,7 +106,20 @@ private function _recursiveParseDirectory($path,$currentdir)
109
106
continue ;
110
107
}
111
108
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 );
113
123
}
114
124
else // we have a file
115
125
{
@@ -181,27 +191,7 @@ private function _recursiveParseDirectory($path,$currentdir)
181
191
} // end isFile
182
192
} // end foreach files/dirs in the directory
183
193
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 );
205
195
return true ;
206
196
} // end _recursiveParseDirectory
207
197
0 commit comments