Skip to content

Commit a28e147

Browse files
committed
removed mongoFsync function because it won't work with the default connection
1 parent c0231c2 commit a28e147

3 files changed

Lines changed: 0 additions & 24 deletions

File tree

app/Console/Commands/Indexer/AnimeIndexer.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ public function handle()
129129

130130
$success[] = $id;
131131
Storage::put('indexer/indexer_anime.save', $i);
132-
133-
// we want to sync to disk after every 300 items to avoid data loss.
134-
if ($i % 300 == 0) {
135-
mongoFsync();
136-
}
137132
}
138133

139134
Storage::delete('indexer/indexer_anime.save');

app/Console/Commands/Indexer/IncrementalIndexer.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ private function fetchIds(string $mediaType, array $idsToFetch, bool $resume): v
150150

151151
$success[] = $id;
152152
Storage::put("indexer/incremental/{$mediaType}_resume.save", $index);
153-
154-
// we want to sync to disk after every 300 items to avoid data loss.
155-
if ($i % 300 == 0) {
156-
mongoFsync();
157-
}
158153
}
159154

160155
Storage::delete("indexer/incremental/{$mediaType}_resume.save");
@@ -168,7 +163,6 @@ private function fetchIds(string $mediaType, array $idsToFetch, bool $resume): v
168163

169164
// finalize the latest state
170165
Storage::move("indexer/incremental/$mediaType.json.tmp", "indexer/incremental/$mediaType.json");
171-
mongoFsync();
172166
}
173167

174168
public function handle(): int

app/Support/helpers.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,3 @@ function ensureEnumPrimitiveValue(int|string|bool|float|null|\Spatie\Enum\Larave
123123
return $value;
124124
}
125125
}
126-
127-
if (!function_exists("mongoFsync")) {
128-
function mongoFsync(bool $async = true): void {
129-
$mongo = Illuminate\Support\Facades\DB::getMongoClient();
130-
$adminDb = $mongo->selectDatabase('admin');
131-
if ($async) {
132-
$adminDb->command(['fsync' => 1]);
133-
} else {
134-
// sync journal too
135-
$adminDb->command(['fsync' => 1, 'async' => false]);
136-
}
137-
}
138-
}

0 commit comments

Comments
 (0)