Kareadita / Kavita

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
http://www.kavitareader.com
GNU General Public License v3.0
6.47k stars 340 forks source link

Files downloaded via OPDS are not renamed #2080

Closed random-human-being closed 1 year ago

random-human-being commented 1 year ago

When downloading (not streaming) a CBZ anrchive via OPDS, Kavita sends the file as it is in the filesystem, with its name unchanged.

Conversely, when downloading a file from the web interface, this is automatically renamed to e.g. "Series Name - Volume N.cbz".

I am assuming the latter is the intended behaviour, and that the former is an oversight.

Tested on 0.7.1 through 0.7.3 (Docker install) using Chunky Reader as client.

majora2007 commented 1 year ago

I had originally left the OPDS implementation to download the raw files, as that is how it was designed for. I can give it the same implementation as using the web downloader if that makes it more consistent.

random-human-being commented 1 year ago

My concern is that the original filenames might give away information I don't want to share with people who use my server, e.g. the source of the files themselves.

Also original filenames can look a bit messy sometimes.

majora2007 commented 1 year ago

That's fair. I'll take a look later, but letting you know it's low priority right now.

majora2007 commented 1 year ago

I took a quick look into this. Here's the deal. Adding this renaming adds a bit of complexity. The issue is that something like Manga might work, we can rename it like the web, but books loose a lot of context, as in Kavita a book might be volume 1, but in the UI it's showing the full title.

I feel like adding this actually makes the implementation worse. Adding all that logic to make it the best experience is also something I'm not interested in personally. If someone wants to try and tackle it, so be it, but it's not something I want to move forward with. Here is the needed code for OPDSController.DownloadFile():

var series = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId);
        var chapter = await _unitOfWork.ChapterRepository.GetChapterAsync(chapterId);

        var files = chapter!.Files;
        var (zipFile, contentType, fileDownloadName) = _downloadService.GetFirstFileDownload(files);
        var dlName = $"{series!.Name} - Chapter {chapter.Number}{Path.GetExtension(fileDownloadName)}";

        if (chapter.Number == Parser.DefaultChapter)
        {
            var volume = await _unitOfWork.VolumeRepository.GetVolumeAsync(volumeId);
            dlName = $"{series!.Name} - Volume {volume.Number}{Path.GetExtension(fileDownloadName)}";
        }