Symlinks (aliases) to categories doesn't have '/' in path ending from now

parent 67af3772
......@@ -234,7 +234,8 @@ void assignAliases(string category,
auto pseudonymPath = vpath ~ pseudonym;
if (!exists(pseudonymPath)) {
symlink(getCatDirPath(category), vpath ~ pseudonym);
string catDir = category.getCatDirPath.stripRight('/');
symlink(catDir, vpath ~ pseudonym);
continue;
}
"warning".tprintln(pseudonym ~ ": this category already exists."._s);
......@@ -251,7 +252,8 @@ void assignAliases(string category,
if (!userDenial && (answer || userConfirmation)) {
"simple".tprintln("The categories are combining."._s);
combineCategories(category, pseudonym);
symlink(getCatDirPath(category), vpath ~ pseudonym);
string catDir = category.getCatDirPath.stripRight('/');
symlink(catDir, vpath ~ pseudonym);
} else {
"warning".tprintln("The request is skipped."._s);
}
......@@ -260,7 +262,6 @@ void assignAliases(string category,
void combineCategories(string mainCategory, string oldCategory) {
string pathToMainCategory = getCatDirPath(mainCategory);
string pathToOldCategory = getCatDirPath(oldCategory);
string[] catDirList = amalthea.fs.getDirListRecurse(pathToOldCategory);
catDirList = pathToOldCategory ~ catDirList;
......@@ -269,7 +270,8 @@ void combineCategories(string mainCategory, string oldCategory) {
string oldSubcategory = oldCategory ~ "/" ~ currSubcategory;
string newSubcategory = mainCategory ~ "/" ~ currSubcategory;
createNonExistentCategory(newSubcategory, true, false);
string pathToNewSubcategory = getCatDirPath(newSubcategory);
string pathToNewSubcategory;
pathToNewSubcategory = newSubcategory.getCatDirPath.stripRight('/');
if (oldSubcategory.isGlobalSubCategory) {
auto globPath = getCatDirPath(oldSubcategory.baseName);
globPath = globPath.stripRight('/');
......@@ -493,6 +495,8 @@ void assignCategoriesToNetLinks(string[] categories,
* The function assigns new name for the category.
*/
void assignNewNameToCategory(string category, string newName) {
category = category.stripRight('/');
newName = newName.stripRight('/');
string msg;
if (getCatDirPath(category).empty) {
msg = category ~ ": this category doesn't exist."._s;
......@@ -515,12 +519,12 @@ void assignNewNameToCategory(string category, string newName) {
if (!msg.empty) throw new FileWarning(msg);
string categoryPath = getCatDirPath(category);
string categoryPath = getCatDirPath(category).stripRight('/');
string superCategory = std.path.dirName(vpath ~ newName);
if (!superCategory.exists) {
std.file.mkdirRecurse(superCategory);
}
std.file.rename(categoryPath.stripRight('/'), vpath ~ newName);
std.file.rename(categoryPath, vpath ~ newName);
categoryPath = vpath ~ newName;
if (newName.canFind('/')) {
......
......@@ -347,10 +347,10 @@ bool isGlobalSubCategory(string thing) {
if (!thing.canFind("/")) { //only: cat/subcat
return false;
}
auto fullPath = getCatDirPath(thing);
auto fullPath = getCatDirPath(thing).stripRight('/');
auto globPath = getCatDirPath(thing.baseName).stripRight('/');
if (fullPath.empty || globPath.empty) return false;
if (globPath.isSymlink && globPath.readLink == fullPath) {
if (globPath.isSymlink && globPath.readLink.stripRight('/') == fullPath) {
return true;
}
return false;
......
......@@ -585,7 +585,7 @@ case_2_1_1() {
$vitis create Moon $OPTCONF
CMD="$vitis assign Moon -a Luna"
$CMD $OPTCONF
if [[ -L ${VTS}/Luna && `readlink ${VTS}/Luna` == ${VTS}/Moon/ ]]; then
if [[ -L ${VTS}/Luna && `readlink ${VTS}/Luna` == ${VTS}/Moon ]]; then
pass "${CMD}"
else
fail "${CMD}"
......@@ -598,7 +598,7 @@ case_2_1_2() {
$vitis create Moon $OPTCONF
CMD="$vitis assign -c Moon -a Luna"
$CMD $OPTCONF
if [[ -L ${VTS}/Luna && `readlink ${VTS}/Luna` == ${VTS}/Moon/ ]]; then
if [[ -L ${VTS}/Luna && `readlink ${VTS}/Luna` == ${VTS}/Moon ]]; then
pass "${CMD}"
else
fail "${CMD}"
......@@ -612,9 +612,9 @@ case_2_1_3() {
CMD="$vitis assign -c Moon -a Luna Hologram Nazi_Base" # ;-)
$CMD $OPTCONF
if [[ -L ${VTS}/Luna && -L ${VTS}/Hologram && -L ${VTS}/Nazi_Base
&& `readlink ${VTS}/Luna` == ${VTS}/Moon/
&& `readlink ${VTS}/Hologram` == ${VTS}/Moon/
&& `readlink ${VTS}/Nazi_Base` == ${VTS}/Moon/ ]]; then
&& `readlink ${VTS}/Luna` == ${VTS}/Moon
&& `readlink ${VTS}/Hologram` == ${VTS}/Moon
&& `readlink ${VTS}/Nazi_Base` == ${VTS}/Moon ]]; then
pass "${CMD}"
else
fail "${CMD}"
......@@ -628,9 +628,9 @@ case_2_1_4() {
CMD="$vitis assign Moon -a Luna Hologram Nazi_Base" # ;-)
$CMD $OPTCONF
if [[ -L ${VTS}/Luna && -L ${VTS}/Hologram && -L ${VTS}/Nazi_Base
&& `readlink ${VTS}/Luna` == ${VTS}/Moon/
&& `readlink ${VTS}/Hologram` == ${VTS}/Moon/
&& `readlink ${VTS}/Nazi_Base` == ${VTS}/Moon/ ]]; then
&& `readlink ${VTS}/Luna` == ${VTS}/Moon
&& `readlink ${VTS}/Hologram` == ${VTS}/Moon
&& `readlink ${VTS}/Nazi_Base` == ${VTS}/Moon ]]; then
pass "${CMD}"
else
fail "${CMD}"
......@@ -675,7 +675,7 @@ case_2_1_7() {
$CMD $OPTCONF
alias_path="${VTS}/Our_Galaxy"
if [[ -d ${VTS}/Milky_Way && -L "$alias_path"
&& `readlink "$alias_path"` == ${VTS}/Milky_Way/ ]]
&& `readlink "$alias_path"` == ${VTS}/Milky_Way ]]
then
pass "${CMD}"
else
......@@ -716,7 +716,7 @@ The request is skipped."
case_2_1_10() {
subtitle "Case 10: Alias for autocategories"
CMD="$vitis assign NetworkBookmarks -a Entries"
category_path=${VTS}/__auto/N/NetworkBookmarks/
category_path=${VTS}/__auto/N/NetworkBookmarks
alias_path=${VTS}/Entries
$CMD $OPTCONF
if [[ -L "${alias_path}"
......@@ -752,11 +752,11 @@ case_2_1_12() {
CMD="$vitis assign Retrowave -a Synthwave --yes"
output=$($CMD $OPTCONF 2>&1)
if [[ -L "${VTS}/Synthwave" && -L "${VTS}/Synthwave/file1.txt"
&& `readlink "${VTS}/Synthwave"` == "${VTS}/Retrowave/"
&& `readlink "${VTS}/Synthwave"` == "${VTS}/Retrowave"
&& `readlink "${VTS}/Retrowave/file1.txt"` == $FILE1
&& -L "${VTS}/Retrowave/1/file2.txt"
&& `readlink "${VTS}/Retrowave/1/file2.txt"` == $FILE2
&& `readlink "${VTS}/1"` == "${VTS}/Retrowave/1/" ]]
&& `readlink "${VTS}/1"` == "${VTS}/Retrowave/1" ]]
then
pass "${CMD}"
else
......@@ -2419,7 +2419,7 @@ case_2_12_1() {
$vitis create Audiofiles $OPTCONF
CMD="$vitis assign Audiofiles -s Music"
$CMD $OPTCONF
if [[ `readlink ${VTS}/Music` == ${VTS}/Audiofiles/Music/
if [[ `readlink ${VTS}/Music` == ${VTS}/Audiofiles/Music
&& -d ${VTS}/Audiofiles/Music ]]; then
pass "${CMD}"
else
......@@ -2436,7 +2436,7 @@ case_2_12_2() {
CMD="$vitis assign Audiofiles -s Music --no"
output=$($CMD $OPTCONF 2>&1)
expected="Music: this category already exists.
/tmp/Vitis/Music -> /tmp/Vitis/Audioclips/
/tmp/Vitis/Music -> /tmp/Vitis/Audioclips
The request is skipped."
if [[ "$expected" == "$output" ]]; then
pass "${CMD}"
......@@ -2497,7 +2497,7 @@ case_2_12_6() {
CMD="$vitis assign Audiofiles -s Music"
$CMD $OPTCONF
if [[ `readlink ${VTS}/Audiofiles/Music/track.mp3` == /tmp/track.mp3
&& `readlink ${VTS}/Music` == ${VTS}/Audiofiles/Music/ ]]; then
&& `readlink ${VTS}/Music` == ${VTS}/Audiofiles/Music ]]; then
pass "${CMD}"
else
fail "${CMD}"
......
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