Skip to content

Commit 327f688

Browse files
committed
fixing index creation + error logging
1 parent 4d5b089 commit 327f688

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Flow/Mongo/MongoFile.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function saveChunk()
9898

9999
return true;
100100
} catch (\Exception $e) {
101+
error_log("Could not store chunk: " . $e->getMessage() . "\n" . $e->getTraceAsString());
101102
try {
102103
if (isset($chunkQuery)) {
103104
$this->config->getGridFs()->chunks->remove($chunkQuery);
@@ -158,13 +159,13 @@ public function deleteChunks()
158159

159160
public function ensureIndices()
160161
{
161-
$gridFs = $this->config->getGridFs();
162+
$chunksCollection = $this->config->getGridFs()->chunks;
162163
$indexKeys = ['files_id' => 1, 'n' => 1];
163164
$indexOptions = ['unique' => true, 'background' => true];
164-
if(method_exists($gridFs, 'createIndex')) { // only available for PECL mongo >= 1.5.0
165-
$gridFs->createIndex($indexKeys, $indexOptions);
165+
if(method_exists($chunksCollection, 'createIndex')) { // only available for PECL mongo >= 1.5.0
166+
$chunksCollection->createIndex($indexKeys, $indexOptions);
166167
} else {
167-
$gridFs->ensureIndex($indexKeys, $indexOptions);
168+
$chunksCollection->ensureIndex($indexKeys, $indexOptions);
168169
}
169170
}
170171

0 commit comments

Comments
 (0)