Merge pull request 'dev' (#13) from dev into master

Reviewed-on: #13
This commit is contained in:
2026-06-27 17:25:18 +00:00
4 changed files with 46 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Helpers\HashesHelpers;
use App\Models\EntryHash;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('hashes:calculate')]
#[Description('Recalculate all hashes for EntryHashes')]
class CalculateAllHashes extends Command
{
public function handle()
{
EntryHash::where('verified', '=', 'TBD')->cursor()->each(function ($entryHash) {
if( ( $hash = HashesHelpers::findHashes( $entryHash->hash_sha1 ) ) !== null ){
$entryHash->filename = $hash->filename;
$entryHash->hash_crc32 = $hash->crc32;
$entryHash->hash_sha1 = $hash->sha1;
$entryHash->verified = HashesHelpers::getReferenceName( $hash->dat_reference_id );
$entryHash->save();
} else {
if( !$entryHash->hash_crc32 || !$entryHash->hash_sha1 )
$entryHash->delete();
else {
if (!$entryHash->filename)
$entryHash->filename = "Unknown";
$entryHash->verified = 'No';
$entryHash->save();
}
}
});
$this->info('Hashes calculated');
}
}

View File

@@ -106,7 +106,9 @@ class StoreEntryRequest extends FormRequest
$rules['new-game-genre'] = 'required_with:new-game-title|integer|nullable|exists:genres,id';
}
if( section_must_be( ['translations', 'romhacks'], $section ) ){
$bypassHashes = $isEdit && $this->user()->can('moderate', $this->route('entry') ) && ($this->input('bypass_hashes') !== null);
if( section_must_be( ['translations', 'romhacks'], $section ) && !$bypassHashes ){
$rules['hashes'] = 'array|required|min:1';
$rules['hashes.*.filename'] = 'required|string|max:512';
$rules['hashes.*.hash_crc32'] = 'required|string|max:512';

View File

@@ -34,7 +34,8 @@ class HashesUpload extends Component
public function mount( array $oldHashes = [] ): void
{
foreach ($oldHashes as $hash) {
$this->addHash( $hash['filename'], $hash['hash_crc32'], $hash['hash_sha1'], $hash['verified'] );
if( isset( $hash['filename'], $hash['hash_crc32'], $hash['hash_sha1'], $hash['verified'] ) )
$this->addHash( $hash['filename'], $hash['hash_crc32'], $hash['hash_sha1'], $hash['verified'] );
}
}

View File

@@ -234,6 +234,9 @@
@if( section_must_be(['romhacks', 'homebrew'], $section ) )
<label><input class="form-checkbox" type="checkbox" name="nsfw-entry" value="1" {{ old('nsfw-entry', $entry->nsfw ) ? 'checked' : '' }}>NSFW</label>
@endif
@if( section_must_be( ['romhacks', 'translations'], $section ) )
<label><input class="form-checkbox" type="checkbox" name="bypass_hashes" value="1">Bypass hashes requirements</label>
@endif
</div>
</div>
@endcan