installer/CopyEngine: don't return values via class states
_CollectCopyInfo uses fBytesToCopy and fItemsToCopy for the sole purpose of returning the scan results. This variable in turn was used to add to the amount of files to copy in the progress bar, causing it to grow exponentially with every CollectTargets calls. With the current use case, the variable would have to be reset to 0 everytime CollectTargets is invoked, making it rather useless as a class state. This commit turns those variables into _CollectCopyInfo return values, and also fix the exponential growth of the progress bar target. Fixes #15826 Change-Id: Ib734febfdd8aaaa12fdfac61be124adb61b28f6c Reviewed-on: https://review.haiku-os.org/c/haiku/+/2445 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
a73bad3ed2
commit
d7e2195b89
@ -55,9 +55,6 @@ CopyEngine::CopyEngine(ProgressReporter* reporter, EntryFilter* entryFilter)
|
||||
fBytesWritten(0),
|
||||
fTimeWritten(0),
|
||||
|
||||
fBytesToCopy(0),
|
||||
fItemsToCopy(0),
|
||||
|
||||
fCurrentTargetFolder(NULL),
|
||||
fCurrentItem(NULL),
|
||||
|
||||
@ -108,9 +105,6 @@ CopyEngine::ResetTargets(const char* source)
|
||||
fBytesWritten = 0;
|
||||
fTimeWritten = 0;
|
||||
|
||||
fBytesToCopy = 0;
|
||||
fItemsToCopy = 0;
|
||||
|
||||
fCurrentTargetFolder = NULL;
|
||||
fCurrentItem = NULL;
|
||||
}
|
||||
@ -120,9 +114,12 @@ status_t
|
||||
CopyEngine::CollectTargets(const char* source, sem_id cancelSemaphore)
|
||||
{
|
||||
int32 level = 0;
|
||||
status_t ret = _CollectCopyInfo(source, level, cancelSemaphore);
|
||||
off_t bytesToCopy = 0;
|
||||
uint64 itemsToCopy = 0;
|
||||
status_t ret = _CollectCopyInfo(source, level, cancelSemaphore, bytesToCopy,
|
||||
itemsToCopy);
|
||||
if (ret == B_OK && fProgressReporter != NULL)
|
||||
fProgressReporter->AddItems(fItemsToCopy, fBytesToCopy);
|
||||
fProgressReporter->AddItems(itemsToCopy, bytesToCopy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -234,7 +231,7 @@ CopyEngine::_CopyData(const BEntry& _source, const BEntry& _destination,
|
||||
|
||||
status_t
|
||||
CopyEngine::_CollectCopyInfo(const char* _source, int32& level,
|
||||
sem_id cancelSemaphore)
|
||||
sem_id cancelSemaphore, off_t& bytesToCopy, uint64& itemsToCopy)
|
||||
{
|
||||
level++;
|
||||
|
||||
@ -277,17 +274,18 @@ CopyEngine::_CollectCopyInfo(const char* _source, int32& level,
|
||||
if (ret < B_OK)
|
||||
return ret;
|
||||
|
||||
ret = _CollectCopyInfo(entryPath.Path(), level, cancelSemaphore);
|
||||
ret = _CollectCopyInfo(entryPath.Path(), level,
|
||||
cancelSemaphore, bytesToCopy, itemsToCopy);
|
||||
if (ret < B_OK)
|
||||
return ret;
|
||||
}
|
||||
} else if (S_ISLNK(statInfo.st_mode)) {
|
||||
// link, ignore size
|
||||
} else {
|
||||
fBytesToCopy += statInfo.st_size;
|
||||
bytesToCopy += statInfo.st_size;
|
||||
}
|
||||
|
||||
fItemsToCopy++;
|
||||
itemsToCopy++;
|
||||
level--;
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
|
||||
private:
|
||||
status_t _CollectCopyInfo(const char* source,
|
||||
int32& level, sem_id cancelSemaphore);
|
||||
int32& level, sem_id cancelSemaphore,
|
||||
off_t& bytesToCopy, uint64& itemsToCopy);
|
||||
status_t _Copy(BEntry& source,
|
||||
BEntry& destination,
|
||||
int32& level, sem_id cancelSemaphore,
|
||||
@ -103,9 +104,6 @@ private:
|
||||
off_t fBytesWritten;
|
||||
bigtime_t fTimeWritten;
|
||||
|
||||
off_t fBytesToCopy;
|
||||
uint64 fItemsToCopy;
|
||||
|
||||
const char* fCurrentTargetFolder;
|
||||
const char* fCurrentItem;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user