Mik1ll / LuaRenamer

Lua file renaming and moving plugin for Shoko. Uses Lua 5.4.
GNU Lesser General Public License v3.0
12 stars 5 forks source link

Disable CleanPathSegment #54

Closed Rand-Random closed 2 months ago

Rand-Random commented 2 months ago

Is it possible to disable this line? https://github.com/Mik1ll/LuaRenamer/blob/70557135a93fb44a96e7dd0ed0232b1b1b534c7a/LuaRenamer/Utils.cs#L36

Why? Because some anime end with a dot, and a foldername is allowed to end with a dot, so there is not use case (atleast for me) to have this code enabled.

Mik1ll commented 2 months ago

Windows does not like spaces/periods at the end of file/directory names, not sure why I only trimmed directories.

I could separate the behavior between Docker/Linux and Windows here. I'll take a look at it soon.

Rand-Random commented 2 months ago

Sorry, that I didn't mention it in my original post. I am using Windows and I can not confirm that Windows has issues with dot at the end for directory names. Files I could see issues, because of "file type" logic, but directories?

Mik1ll commented 2 months ago

Sorry, that I didn't mention it in my original post. I am using Windows and I can not confirm that Windows has issues with dot at the end for directory names. Files I could see issues, because of "file type" logic, but directories?

Well, you can test it for yourself via CLI or Explorer: image

Rand-Random commented 2 months ago

News to me, thanks for sharing the info.

I am in the middle of replacing my old script renamer ( https://github.com/Mik1ll/ScriptRenamer ), to this renamer, and one of the visible changes were that "a dot" was removed from the end.

I didn't confirm what I was seeing is the actual . character and not ․

Shoko seems to have magic, for exactly this case when it ends with . replace it with the looks like a dot but isn't one character https://github.com/ShokoAnime/ShokoServer/blob/9d161837337df7ae3bb8f354aef845752d8ad0d7/Shoko.Server/Utils.cs#L637

Rand-Random commented 2 months ago

This seems to give the result I desire:

if animename:match("^%.") then
  animename = "․" .. animename:sub(2)
end
if animename:match("%.$") then
  animename = animename:sub(1, animename:len() - 1) .. "․"
end

by replacing the . character with this special variant of a dot, I have the same result as I had it previously.

Mik1ll commented 2 months ago

Glad you figured it out, closing this issue as solved and will make another one regarding platform dependent path handling.