From f2c05727c232b607be5a3b8b78279a669b1e7ef3 Mon Sep 17 00:00:00 2001 From: upstream svn Date: Sat, 16 Apr 2016 19:16:44 +0000 Subject: [PATCH] Fix crash when importing partfiles with the "Preallocate space for new 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. --- .svn-revision | 2 +- docs/Changelog | 1 + src/PartFile.cpp | 4 ++-- src/PartFile.h | 2 +- src/PartFileConvert.cpp | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.svn-revision b/.svn-revision index b0f5b8a5..7d97214e 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10919 +10920 diff --git a/docs/Changelog b/docs/Changelog index 158aadda..ef4dd59d 100644 --- a/docs/Changelog +++ b/docs/Changelog @@ -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 diff --git a/src/PartFile.cpp b/src/PartFile.cpp index e3705f1b..34a0d92d 100644 --- a/src/PartFile.cpp +++ b/src/PartFile.cpp @@ -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 { diff --git a/src/PartFile.h b/src/PartFile.h index 72886f94..ed222131 100644 --- a/src/PartFile.h +++ b/src/PartFile.h @@ -307,7 +307,7 @@ private: 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 ); diff --git a/src/PartFileConvert.cpp b/src/PartFileConvert.cpp index c025c362..8427f31e 100644 --- a/src/PartFileConvert.cpp +++ b/src/PartFileConvert.cpp @@ -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(); -- 2.11.4.GIT