mirror of
https://github.com/aria2/aria2.git
synced 2025-01-04 09:03:46 +00:00
Refactor MultiDiskAdaptor::closeFile() and add assert for debugging
This commit is contained in:
parent
b324be70ad
commit
d03c7b32c6
@ -141,6 +141,7 @@ std::unique_ptr<DiskWriterEntry> createDiskWriterEntry
|
||||
|
||||
void MultiDiskAdaptor::resetDiskWriterEntries()
|
||||
{
|
||||
assert(openedDiskWriterEntries_.empty());
|
||||
diskWriterEntries_.clear();
|
||||
if(getFileEntries().empty()) {
|
||||
return;
|
||||
@ -271,18 +272,19 @@ void MultiDiskAdaptor::openExistingFile()
|
||||
|
||||
void MultiDiskAdaptor::closeFile()
|
||||
{
|
||||
size_t n = 0;
|
||||
openedDiskWriterEntries_.clear();
|
||||
for(auto& dwent : diskWriterEntries_) {
|
||||
if(dwent->isOpen()) {
|
||||
++n;
|
||||
dwent->closeFile();
|
||||
for(auto& dwent : openedDiskWriterEntries_) {
|
||||
auto& dw = dwent->getDiskWriter();
|
||||
// required for unit test
|
||||
if (!dw) {
|
||||
continue;
|
||||
}
|
||||
dw->closeFile();
|
||||
}
|
||||
auto& openedFileCounter = getOpenedFileCounter();
|
||||
if(openedFileCounter) {
|
||||
openedFileCounter->reduceNumOfOpenedFile(n);
|
||||
openedFileCounter->reduceNumOfOpenedFile(openedDiskWriterEntries_.size());
|
||||
}
|
||||
openedDiskWriterEntries_.clear();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
Loading…
Reference in New Issue
Block a user