Merge pull request #452 from shikorism/fix/451-atomic-metadata-resolve

Metadata解決処理をトランザクション内で実行する
This commit is contained in:
shibafu 2020-08-01 18:48:13 +09:00 committed by GitHub
commit a63c39a56f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ use App\MetadataResolver\MetadataResolver;
use App\Tag; use App\Tag;
use App\Utilities\Formatter; use App\Utilities\Formatter;
use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Exception\TransferException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class MetadataResolveService class MetadataResolveService
@ -33,6 +34,7 @@ class MetadataResolveService
throw new DeniedHostException($url); throw new DeniedHostException($url);
} }
return DB::transaction(function () use ($url) {
// 無かったら取得 // 無かったら取得
// TODO: ある程度古かったら再取得とかありだと思う // TODO: ある程度古かったら再取得とかありだと思う
$metadata = Metadata::find($url); $metadata = Metadata::find($url);
@ -60,5 +62,6 @@ class MetadataResolveService
} }
return $metadata; return $metadata;
});
} }
} }