Skip to content

Commit

Permalink
Fix crash when importing partfiles with the "Preallocate space for ne…
Browse files Browse the repository at this point in the history
…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 393acf5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/PartFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/PartFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/PartFileConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 393acf5

Please sign in to comment.