Corrected deleting aliases of subcategories. Closed #20

parent 7c42b326
......@@ -69,10 +69,10 @@ void mainFn(string[] args) {
void deleteCategories(string[] categories, bool force = false) {
static void deleteAliasesOfCategory(string category) {
auto allAliases = getAliases(Yes.fullPath);
void deleteAliasesOfCategory(string category) {
auto categoryPath = getCatDirPath(category);
auto categories = getAliases(Yes.fullPath);
foreach(cat; categories) {
foreach(cat; allAliases) {
if (categoryPath == readLink(cat)) {
rm(cat);
}
......@@ -100,10 +100,21 @@ void deleteCategories(string[] categories, bool force = false) {
categoryPath = getCatDirPath(category);
}
deleteAliasesOfCategory(category);
auto subcategories = getSubcategories(category);
deleteCategories(subcategories, force);
rmdirRecurse(categoryPath);
}
}
string[] getSubcategories(string category) {
auto categoryPath = getCatDirPath(category);
auto dirList = amalthea.fs.getDirList(categoryPath);
foreach(ref dir; dirList) {
dir = category ~ "/" ~ dir[categoryPath.length .. $];
}
return dirList;
}
void deleteCategoryFromFile(string category,
string filename,
......
......@@ -347,8 +347,8 @@ void checkFileFormats(string category = "") {
}
//we create new link in new format category
auto w = ": this file is assigned new format category";
auto category = "Format/" ~ fileType.format;
auto msg = format("%s %s (%s).", linkpath, w, category);
auto formatCategory = "Format/" ~ fileType.format;
auto msg = format("%s %s (%s).", linkpath, w, formatCategory);
"warning".tprintln(msg);
symlink(filepath, formatCatPath ~ linkpath.baseName);
}
......@@ -372,8 +372,8 @@ void checkFileFormats(string category = "") {
}
//we create new link in new type category
auto w = ": this file is assigned new type category";
auto category = "Type/" ~ fileType.category;
auto msg = format("%s %s (%s).", linkpath, w, category);
auto typeCategory = "Type/" ~ fileType.category;
auto msg = format("%s %s (%s).", linkpath, w, typeCategory);
"warning".tprintln(msg);
symlink(filepath, typeCatPath ~ linkpath.baseName);
}
......
......@@ -614,10 +614,10 @@ auto findFileInVitis(string vitisFile,
}
size_t[string] numbersOfRepeatedFiles =
groupByFilePathWithNumbers(files);
foreach(linkpath, n; numbersOfRepeatedFiles) {
if (n == number && linkpath.baseName == linkName) {
finalFilepath = linkpath.readLink;
finalLinkpath = linkpath;
foreach(lpath, n; numbersOfRepeatedFiles) {
if (n == number && lpath.baseName == linkName) {
finalFilepath = lpath.readLink;
finalLinkpath = lpath;
break;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment