Skip to content

Commit b79429d

Browse files
committed
Fix delete course folder.
1 parent 8f3a7a5 commit b79429d

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

main/install/update-files-1.9.0-1.10.0.inc.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@
182182

183183

184184
// Delete all "courses/ABC/index.php" files.
185-
$courseDir = api_get_path(SYS_APP_PATH).'courses';
186185
$finder = new Finder();
187186

187+
$courseDir = api_get_path(SYS_APP_PATH).'courses';
188188
if (is_dir($courseDir)) {
189-
$dirs = $finder->directories()->in(api_get_path(SYS_APP_PATH).'courses');
189+
$dirs = $finder->directories()->in($courseDir);
190190
$fs = new Filesystem();
191191
/** @var Symfony\Component\Finder\SplFileInfo $dir */
192192
foreach ($dirs as $dir) {
@@ -197,18 +197,23 @@
197197
}
198198
}
199199

200-
// Remove archive
201-
@rrmdir(api_get_path(SYS_PATH).'archive');
202-
203200
// Remove old "courses" folder if empty
204-
$dirs = $finder->directories()->in(api_get_path(SYS_PATH).'courses');
205-
$files = $finder->directories()->in(api_get_path(SYS_PATH).'courses');
206-
$dirCount = $dirs->count();
207-
$fileCount = $dirs->count();
208-
if ($fileCount == 0 && $dirCount == 0) {
209-
@rrmdir(api_get_path(SYS_PATH).'courses');
201+
$originalCourseDir = api_get_path(SYS_PATH).'courses';
202+
203+
if (is_dir($originalCourseDir)) {
204+
$dirs = $finder->directories()->in($originalCourseDir);
205+
$files = $finder->directories()->in($originalCourseDir);
206+
$dirCount = $dirs->count();
207+
$fileCount = $dirs->count();
208+
if ($fileCount == 0 && $dirCount == 0) {
209+
@rrmdir(api_get_path(SYS_PATH).'courses');
210+
}
210211
}
211212

213+
214+
// Remove archive
215+
@rrmdir(api_get_path(SYS_PATH).'archive');
216+
212217
} else {
213218
echo 'You are not allowed here !'. __FILE__;
214219
}

0 commit comments

Comments
 (0)