Skip to content

Commit

Permalink
Restore ability to use server-side translation by custom WebUI
Browse files Browse the repository at this point in the history
PR #20711.
  • Loading branch information
glassez committed Apr 27, 2024
1 parent 694661d commit 769de08
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/webui/webapplication.cpp
Expand Up @@ -114,7 +114,7 @@ namespace

if ((contentType == Http::CONTENT_TYPE_CSS)
|| (contentType == Http::CONTENT_TYPE_JS))
{
{
// short interval in case of program update
return u"private, max-age=43200"_s; // 12 hrs
}
Expand Down Expand Up @@ -520,15 +520,12 @@ void WebApplication::sendFile(const Path &path)
const QDateTime lastModified = Utils::Fs::lastModified(path);

// find translated file in cache
if (!m_isAltUIUsed)
if (const auto it = m_translatedFiles.constFind(path);
(it != m_translatedFiles.constEnd()) && (lastModified <= it->lastModified))
{
if (const auto it = m_translatedFiles.constFind(path);
(it != m_translatedFiles.constEnd()) && (lastModified <= it->lastModified))
{
print(it->data, it->mimeType);
setHeader({Http::HEADER_CACHE_CONTROL, getCachingInterval(it->mimeType)});
return;
}
print(it->data, it->mimeType);
setHeader({Http::HEADER_CACHE_CONTROL, getCachingInterval(it->mimeType)});
return;
}

const auto readResult = Utils::IO::readFile(path, MAX_ALLOWED_FILESIZE);
Expand Down Expand Up @@ -559,7 +556,7 @@ void WebApplication::sendFile(const Path &path)

QByteArray data = readResult.value();
const QMimeType mimeType = QMimeDatabase().mimeTypeForFileNameAndData(path.data(), data);
const bool isTranslatable = !m_isAltUIUsed && mimeType.inherits(u"text/plain"_s);
const bool isTranslatable = mimeType.inherits(u"text/plain"_s);

if (isTranslatable)
{
Expand Down

0 comments on commit 769de08

Please sign in to comment.