Skip to content

Commit 5d3fee1

Browse files
committed
optimized MongoFile.validateFile performance
1 parent 55d8bde commit 5d3fee1

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/Flow/Mongo/MongoFile.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,11 @@ public function saveChunk($additionalUpdateOptions = [])
112112
*/
113113
public function validateFile()
114114
{
115-
$totalChunks = $this->request->getTotalChunks();
116-
117-
for ($i = 1; $i <= $totalChunks; $i++) {
118-
if (!$this->chunkExists($i)) {
119-
return false;
120-
}
121-
}
122-
123-
return true;
115+
$totalChunks = intval($this->request->getTotalChunks());
116+
$storedChunks = $this->config->getGridFs()->chunks
117+
->find(['files_id' => $this->getGridFsFile()['_id']])
118+
->count();
119+
return $totalChunks === $storedChunks;
124120
}
125121

126122

0 commit comments

Comments
 (0)