Fixed bad permission access that caused an application loop
This commit is contained in:
@@ -54,10 +54,24 @@ Transcoder::Transcoder(const std::filesystem::path& filePath, const TranscodePar
|
|||||||
bool
|
bool
|
||||||
Transcoder::start()
|
Transcoder::start()
|
||||||
{
|
{
|
||||||
if (!std::filesystem::exists(_filePath))
|
try
|
||||||
return false;
|
{
|
||||||
else if (!std::filesystem::is_regular_file( _filePath) )
|
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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Transcoding file '" << _filePath.string() << "'";
|
LOG(INFO) << "Transcoding file '" << _filePath.string() << "'";
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ FileResourceHandler::processRequest(const Wt::Http::Request& request, Wt::Http::
|
|||||||
::uint64_t startByte {_offset};
|
::uint64_t startByte {_offset};
|
||||||
std::ifstream ifs {_path.string().c_str(), std::ios::in | std::ios::binary};
|
std::ifstream ifs {_path.string().c_str(), std::ios::in | std::ios::binary};
|
||||||
|
|
||||||
LMS_LOG(UTILS, DEBUG) << "startByte = " << startByte;
|
|
||||||
|
|
||||||
if (startByte == 0)
|
if (startByte == 0)
|
||||||
{
|
{
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
@@ -100,6 +98,12 @@ FileResourceHandler::processRequest(const Wt::Http::Request& request, Wt::Http::
|
|||||||
response.setContentLength(_beyondLastByte);
|
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));
|
ifs.seekg(static_cast<std::istream::pos_type>(startByte));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user