Fixed bad permission access that caused an application loop

This commit is contained in:
emeric
2020-05-20 23:17:30 +02:00
parent 790bc3bad1
commit 4e998fd507
2 changed files with 23 additions and 5 deletions
+14
View File
@@ -53,11 +53,25 @@ Transcoder::Transcoder(const std::filesystem::path& filePath, const TranscodePar
bool
Transcoder::start()
{
try
{
if (!std::filesystem::exists(_filePath))
{
LOG(ERROR) << "File '" << _filePath << "' does not exist!";
return false;
}
else if (!std::filesystem::is_regular_file( _filePath) )
{
LOG(ERROR) << "File '" << _filePath << "' is not regular!";
return false;
}
}
catch (const std::filesystem::filesystem_error& e)
{
LOG(ERROR) << "File error on '" << _filePath.string() << "': " << e.what();
return false;
}
LOG(INFO) << "Transcoding file '" << _filePath.string() << "'";
+6 -2
View File
@@ -42,8 +42,6 @@ FileResourceHandler::processRequest(const Wt::Http::Request& request, Wt::Http::
::uint64_t startByte {_offset};
std::ifstream ifs {_path.string().c_str(), std::ios::in | std::ios::binary};
LMS_LOG(UTILS, DEBUG) << "startByte = " << startByte;
if (startByte == 0)
{
if (!ifs)
@@ -100,6 +98,12 @@ FileResourceHandler::processRequest(const Wt::Http::Request& request, Wt::Http::
response.setContentLength(_beyondLastByte);
}
}
else if (!ifs)
{
LMS_LOG(UTILS, ERROR) << "Cannot reopen file stream for '" << _path.string() << "'";
_isFinished = true;
return;
}
ifs.seekg(static_cast<std::istream::pos_type>(startByte));