Skip to content

Commit

Permalink
changes from self review
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed Aug 12, 2024
1 parent 75b856b commit bc08e05
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions backend/handler/filesystem/roms_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def get_rom_hashes(self, rom: str, roms_path: str) -> dict[str, str]:
multi_files = os.listdir(f"{roms_file_path}/{rom}")
for file in self._exclude_files(multi_files, "multi_parts"):
path = Path(roms_file_path, rom, file)
# Pass the raw hashes to the next iteration
crc_c, md5_h, sha1_h = self._calculate_rom_hashes(
path, crc_c, md5_h, sha1_h
)
Expand Down
4 changes: 3 additions & 1 deletion backend/handler/scan_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ScanType(Enum):
UNIDENTIFIED = "unidentified"
PARTIAL = "partial"
COMPLETE = "complete"
HASH_SCAN = "no_scan"
HASH_SCAN = "hash_scan"


async def _get_main_platform_igdb_id(platform: Platform):
Expand Down Expand Up @@ -230,6 +230,7 @@ async def scan_rom(
}
)

# Calculating hashes is expensive, so we only do it if necessary
if not rom or scan_type == ScanType.COMPLETE or scan_type == ScanType.HASH_SCAN:
rom_hashes = fs_rom_handler.get_rom_hashes(rom_attrs["file_name"], roms_path)
rom_attrs.update(**rom_hashes)
Expand Down Expand Up @@ -273,6 +274,7 @@ async def fetch_moby_rom():

return MobyGamesRom(moby_id=None)

# Run both metadata fetches concurrently
igdb_handler_rom, moby_handler_rom = await asyncio.gather(
fetch_igdb_rom(), fetch_moby_rom()
)
Expand Down
15 changes: 8 additions & 7 deletions frontend/src/components/Details/Info/FileInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ watch(
variant="flat"
rounded="0"
size="small"
class="ml-2"
@click="toggleMainSibling"
><v-icon
:class="romUser.is_main_sibling ? '' : 'mr-1'"
Expand Down Expand Up @@ -133,17 +134,17 @@ watch(
<span>Info</span>
</v-col>
<v-col>
<v-chip size="small" label>
<v-chip size="small" label class="mx-1 my-1">
Size: {{ formatBytes(rom.file_size_bytes) }}
</v-chip>
<v-chip v-if="!rom.multi && rom.sha1_hash" size="small" label class="mx-2">
SHA-1 Hash: {{ rom.sha1_hash }}
<v-chip v-if="!rom.multi && rom.sha1_hash" size="small" label class="mx-1 my-1">
SHA-1: {{ rom.sha1_hash }}
</v-chip>
<v-chip v-if="!rom.multi && rom.md5_hash" size="small" label class="mx-2">
MD5 Hash: {{ rom.md5_hash }}
<v-chip v-if="!rom.multi && rom.md5_hash" size="small" label class="mx-1 my-1">
MD5: {{ rom.md5_hash }}
</v-chip>
<v-chip v-if="!rom.multi && rom.crc_hash" size="small" label class="mx-2">
CRC Hash: {{ rom.crc_hash }}
<v-chip v-if="!rom.multi && rom.crc_hash" size="small" label class="mx-1 my-1">
CRC: {{ rom.crc_hash }}
</v-chip>
</v-col>
</v-row>
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/Details/VersionSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const router = useRouter();
const version = ref(props.rom.id);
// Functions
function formatSubtitle(rom: DetailedRom) {
function formatTitle(rom: DetailedRom) {
const langs = rom.languages.map((l) => languageToEmoji(l)).join(" ");
const regions = rom.regions.map((r) => regionToEmoji(r)).join(" ");
const tags = rom.tags.map((t) => `(${t})`).join(" ");
Expand All @@ -38,8 +38,7 @@ function updateVersion() {
hide-details
:items="
[rom, ...rom.sibling_roms].map((i) => ({
title: i.file_name,
props: { subtitle: formatSubtitle(i) },
title: formatTitle(i),
value: i.id,
}))
"
Expand Down

0 comments on commit bc08e05

Please sign in to comment.