Permalink
Browse files

Fix crash when importing partfiles with the "Preallocate space for ne…

…w files" preference option enabled

Imported parfiles won't have their space preallocated even if it is requested
in the preferences. The whole importing strategy should be changed for that, and
we'd lose many optimizations meanwhile.

On the other hand, the "create sparse files" preference setting is taken into
account.
  • Loading branch information...
gonosztopi committed Apr 16, 2016
1 parent c815440 commit 393acf5ce78dfdabd7316c44a78511db1c7bae74
Showing with 6 additions and 5 deletions.
  1. +1 −0 docs/Changelog
  2. +2 −2 src/PartFile.cpp
  3. +1 −1 src/PartFile.h
  4. +2 −2 src/PartFileConvert.cpp
@@ -28,6 +28,7 @@ Version 2.4.0 - The river knows.
* Fix bug #1711: Kad Info tab should display my own user ID
* Fix wrong sized images in the priscilla skin
* Fix bug #1423: Add the possibility to not create sparse files
* Fix bug #1743: crash when importing part files

iz0bbz:
* Fix WinSock library version detection with MinGW-w64
@@ -269,7 +269,7 @@ CPartFile::~CPartFile()
wxASSERT(m_A4AFsrclist.empty());
}

void CPartFile::CreatePartFile()
void CPartFile::CreatePartFile(bool isImporting)
{
// use lowest free partfilenumber for free file (InterCeptor)
int i = 0;
@@ -298,7 +298,7 @@ void CPartFile::CreatePartFile()

SetFilePath(thePrefs::GetTempDir());

if (thePrefs::GetAllocFullFile()) {
if (!isImporting && thePrefs::GetAllocFullFile()) {
SetStatus(PS_ALLOCATING);
CThreadScheduler::AddTask(new CAllocateFileTask(this, thePrefs::AddNewFilesPaused()));
} else {
@@ -307,7 +307,7 @@ class CPartFile : public CKnownFile {
bool GetNextEmptyBlockInPart(uint16 partnumber,Requested_Block_Struct* result);
bool IsAlreadyRequested(uint64 start, uint64 end);
void CompleteFile(bool hashingdone);
void CreatePartFile();
void CreatePartFile(bool isImporting = false);
void Init();

bool CheckFreeDiskSpace( uint64 neededSpace = 0 );
@@ -310,7 +310,7 @@ ConvStatus CPartFileConvert::performConvertToeMule(const CPath& fileName)
}

// create new partmetfile, and remember the new name
file->CreatePartFile();
file->CreatePartFile(true);
newfilename = file->GetFullName();

Notify_ConvertUpdateProgress(8, _("Creating destination file"));
@@ -378,7 +378,7 @@ ConvStatus CPartFileConvert::performConvertToeMule(const CPath& fileName)
return CONV_OUTOFDISKSPACE;
}

file->CreatePartFile();
file->CreatePartFile(true);
newfilename = file->GetFullName();

file->m_hpartfile.Close();

0 comments on commit 393acf5

Please sign in to comment.