Skip to content

Commit b61f870

Browse files
authored
Merge pull request #80 from maths/iss79
iss79 - Don't rely on file order to find base category name.
2 parents f8f915a + 8aae4be commit b61f870

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

classes/import_repo.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,11 @@ public function import_categories(): void {
592592
// Categories will be dealt with before their sub-categories. Beyond that,
593593
// order is uncertain.
594594

595-
if (!$this->subdirectory || $this->subdirectory === 'top') {
595+
if (!$this->subdirectory || $this->subdirectory === 'top' || !$this->targetcategory) {
596596
$this->basecategoryname = 'top';
597597
} else {
598-
$this->basecategoryname = null;
598+
$this->basecategoryname =
599+
cli_helper::get_question_category_from_file($subdirectory . '/' . cli_helper::CATEGORY_FILE . '.xml');
599600
}
600601
foreach ($this->repoiterator as $repoitem) {
601602
if ($repoitem->isFile()) {
@@ -619,12 +620,9 @@ public function import_categories(): void {
619620
}
620621
}
621622
if ($this->targetcategory) {
622-
if (!$this->basecategoryname) {
623-
// If target category is not top,
624-
// the first category file we encounter will be for the target category.
623+
if (pathinfo($repoitem, PATHINFO_DIRNAME) === $subdirectory) {
625624
// This must already exist. (We've checked!).
626-
// Set base category name and skip upload.
627-
$this->basecategoryname = $qcategoryname;
625+
// Skip upload.
628626
continue;
629627
}
630628
// Strip base name from category name and replace with target category.

0 commit comments

Comments
 (0)