Intermiediary commit.

This commit is contained in:
Shyotl
2019-03-16 17:51:00 -05:00
parent 7cf55fa993
commit 2d8fbb89c9
58 changed files with 1857 additions and 1057 deletions

View File

@@ -98,16 +98,16 @@ void LLXfer_File::cleanup ()
mFp = NULL;
}
LLFile::remove(mTempFilename);
LLFile::remove(mTempFilename, ENOENT);
if (mDeleteLocalOnCompletion)
{
LL_DEBUGS() << "Removing file: " << mLocalFilename << LL_ENDL;
LLFile::remove(mLocalFilename);
LL_DEBUGS("Xfer") << "Removing file: " << mLocalFilename << LL_ENDL;
LLFile::remove(mLocalFilename, ENOENT);
}
else
{
LL_DEBUGS() << "Keeping local file: " << mLocalFilename << LL_ENDL;
LL_DEBUGS("Xfer") << "Keeping local file: " << mLocalFilename << LL_ENDL;
}
LLXfer::cleanup();
@@ -139,7 +139,7 @@ S32 LLXfer_File::initializeRequest(U64 xfer_id,
mCallbackDataHandle = user_data;
mCallbackResult = LL_ERR_NOERR;
LL_INFOS() << "Requesting xfer from " << remote_host << " for file: " << mLocalFilename << LL_ENDL;
LL_INFOS("Xfer") << "Requesting xfer from " << remote_host << " for file: " << mLocalFilename << LL_ENDL;
if (mBuffer)
{
@@ -182,7 +182,7 @@ S32 LLXfer_File::startDownload()
}
else
{
LL_WARNS() << "Couldn't create file to be received!" << LL_ENDL;
LL_WARNS("Xfer") << "Couldn't create file to be received!" << LL_ENDL;
retval = -1;
}
@@ -223,7 +223,7 @@ S32 LLXfer_File::startSend (U64 xfer_id, const LLHost &remote_host)
}
else
{
LL_INFOS() << "Warning: " << mLocalFilename << " not found." << LL_ENDL;
LL_INFOS("Xfer") << "Warning: " << mLocalFilename << " not found." << LL_ENDL;
return (LL_ERR_FILE_NOT_FOUND);
}
@@ -232,6 +232,36 @@ S32 LLXfer_File::startSend (U64 xfer_id, const LLHost &remote_host)
return (retval);
}
///////////////////////////////////////////////////////////
void LLXfer_File::closeFileHandle()
{
if (mFp)
{
fclose(mFp);
mFp = NULL;
}
}
///////////////////////////////////////////////////////////
S32 LLXfer_File::reopenFileHandle()
{
S32 retval = LL_ERR_NOERR; // presume success
if (mFp == NULL)
{
mFp = LLFile::fopen(mLocalFilename,"rb"); /* Flawfinder : ignore */
if (mFp == NULL)
{
LL_INFOS("Xfer") << "Warning: " << mLocalFilename << " not found when re-opening file" << LL_ENDL;
retval = LL_ERR_FILE_NOT_FOUND;
}
}
return retval;
}
///////////////////////////////////////////////////////////
S32 LLXfer_File::getMaxBufferSize ()
@@ -279,18 +309,21 @@ S32 LLXfer_File::flush()
{
if (mFp)
{
LL_ERRS() << "Overwriting open file pointer!" << LL_ENDL;
LL_ERRS("Xfer") << "Overwriting open file pointer!" << LL_ENDL;
}
mFp = LLFile::fopen(mTempFilename,"a+b"); /* Flawfinder : ignore */
if (mFp)
{
if (fwrite(mBuffer,1,mBufferLength,mFp) != mBufferLength)
S32 write_size = fwrite(mBuffer,1,mBufferLength,mFp);
if (write_size != mBufferLength)
{
LL_WARNS() << "Short write" << LL_ENDL;
LL_WARNS("Xfer") << "Non-matching write size, requested " << mBufferLength
<< " but wrote " << write_size
<< LL_ENDL;
}
// LL_INFOS() << "******* wrote " << mBufferLength << " bytes of file xfer" << LL_ENDL;
// LL_INFOS("Xfer") << "******* wrote " << mBufferLength << " bytes of file xfer" << LL_ENDL;
fclose(mFp);
mFp = NULL;
@@ -298,7 +331,7 @@ S32 LLXfer_File::flush()
}
else
{
LL_WARNS() << "LLXfer_File::flush() unable to open " << mTempFilename << " for writing!" << LL_ENDL;
LL_WARNS("Xfer") << "LLXfer_File::flush() unable to open " << mTempFilename << " for writing!" << LL_ENDL;
retval = LL_ERR_CANNOT_OPEN_FILE;
}
}
@@ -321,7 +354,7 @@ S32 LLXfer_File::processEOF()
mCallbackResult = flushval;
}
LLFile::remove(mLocalFilename);
LLFile::remove(mLocalFilename, ENOENT);
if (!mCallbackResult)
{
@@ -329,18 +362,18 @@ S32 LLXfer_File::processEOF()
{
#if !LL_WINDOWS
S32 error_number = errno;
LL_INFOS() << "Rename failure (" << error_number << ") - "
LL_INFOS("Xfer") << "Rename failure (" << error_number << ") - "
<< mTempFilename << " to " << mLocalFilename << LL_ENDL;
if(EXDEV == error_number)
{
if(copy_file(mTempFilename, mLocalFilename) == 0)
{
LL_INFOS() << "Rename across mounts; copying+unlinking the file instead." << LL_ENDL;
LL_INFOS("Xfer") << "Rename across mounts; copying+unlinking the file instead." << LL_ENDL;
unlink(mTempFilename.c_str());
}
else
{
LL_WARNS() << "Copy failure - " << mTempFilename << " to "
LL_WARNS("Xfer") << "Copy failure - " << mTempFilename << " to "
<< mLocalFilename << LL_ENDL;
}
}
@@ -354,11 +387,11 @@ S32 LLXfer_File::processEOF()
//LL_WARNS() << "File " << mLocalFilename << " does "
// << (!fp ? "not" : "" ) << " exit." << LL_ENDL;
//if(fp) fclose(fp);
LL_WARNS() << "Rename fatally failed, can only handle EXDEV ("
LL_WARNS("Xfer") << "Rename fatally failed, can only handle EXDEV ("
<< EXDEV << ")" << LL_ENDL;
}
#else
LL_WARNS() << "Rename failure - " << mTempFilename << " to "
LL_WARNS("Xfer") << "Rename failure - " << mTempFilename << " to "
<< mLocalFilename << LL_ENDL;
#endif
}