Skip to content

Commit

Permalink
Merge branch 'main' into emmercm/reduce-default-threads
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Apr 7, 2024
2 parents a832ced + 45596f8 commit c2a07c5
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $ igir --help
| $$ | $$| \ | $$ | $$ $$ ROM collection manager
| $$ | $$| \ | $$ | $$ $$ https://igir.io/
| $$ | $$ \$$$$ | $$ | $$$$$$$\
_| $$_ | $$__| $$ _| $$_ | $$ | $$ v2.6.1
_| $$_ | $$__| $$ _| $$_ | $$ | $$ v2.6.2
| $$ \ \$$ $$| $$ \| $$ | $$
\$$$$$$ \$$$$$$ \$$$$$$ \$$ \$$
Expand Down Expand Up @@ -247,6 +247,7 @@ Advanced usage:
{pocket} The ROM's core-specific /Assets/* directory for the Analogue Pocket (e.g. "gb")
{retrodeck} The ROM's emulator-specific /roms/* directory for the 'RetroDECK' image (e.g. "g
b")
{romm} The ROM's manager-specific /roms/* directory for 'RomM' (e.g. "gb")
{twmenu} The ROM's emulator-specific /roms/* directory for TWiLightMenu++ on the DSi/3DS
(e.g. "gb")
Expand Down
1 change: 1 addition & 0 deletions docs/output/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ To help sort ROMs into unique file structures for popular frontends & hardware,
- `{onion}` the [OnionOS / GarlicOS](../usage/handheld/onionos.md) emulator's directory for the ROM
- `{pocket}` the [Analogue Pocket](../usage/hardware/analogue-pocket.md) core's directory for the ROM
- `{retrodeck}` the [RetroDECK](../usage/desktop/retrodeck.md) emulator's directory for the ROM
- `{romm}` the [RomM](../usage/desktop/romm.md) manager directory for the ROM
- `{twmenu}` the [TWiLightMenu++](../usage/handheld/twmenu.md) emulator's directory for the ROM

!!! tip
Expand Down
91 changes: 91 additions & 0 deletions docs/usage/desktop/romm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# RomM

[RomM](https://github.com/rommapp/romm) is a web-based ROM management solution that allows you to scan, enrich, and browse your game collection with a clean and responsive interface. With support for multiple platforms, various naming schemes, and custom tags, RomM is a must-have for anyone who plays on emulators.

## ROMs

RomM uses its own [proprietary ROM folder structure](https://github.com/rommapp/romm/wiki/Supported-Platforms), so `igir` has a replaceable `{romm}` token to sort ROMs into the right place. See the [replaceable tokens page](../../output/tokens.md) for more information.

You can run RomM using [Docker Compose](https://docs.docker.com/compose/). Create a file named `docker-compose.yml` with the following contents, but change all of the environment variables with the value of `CHANGEME!`:

```yaml
version: "3"

# https://github.com/rommapp/romm/blob/997d2cacd4b1980484eb63c2b3ffe65c83133966/examples/docker-compose.example.yml
services:
romm:
image: rommapp/romm
container_name: romm
restart: unless-stopped
environment:
- DB_HOST=romm-db
- DB_NAME=romm
- DB_USER=romm
- DB_PASSWD=CHANGEME!
- ENABLE_RESCAN_ON_FILESYSTEM_CHANGE=true
- ENABLE_SCHEDULED_RESCAN=true
- IGDB_CLIENT_ID=CHANGEME!
- IGDB_CLIENT_SECRET=CHANGEME!
- ROMM_AUTH_SECRET_KEY=CHANGEME!
- ROMM_AUTH_USERNAME=admin
- ROMM_AUTH_PASSWORD=CHANGEME!
volumes:
- ./romm/assets:/romm/assets
- ./romm/config:/romm/config
- ./romm/logs:/romm/logs
- ./romm/redis:/redis-data
- ./romm/resources:/romm/resources
- ./romm/roms:/romm/library/roms
ports:
- 80:8080
depends_on:
- romm-db
romm-db:
image: mariadb:latest
container_name: romm-mariadb
restart: unless-stopped
environment:
- MARIADB_RANDOM_ROOT_PASSWORD=true
- MARIADB_DATABASE=romm
- MARIADB_USER=romm
- MARIADB_PASSWORD=CHANGEME!
expose:
- 3306
volumes:
- ./romm-db:/var/lib/mysql
```
then, run Docker Compose as you would with any other config:
```shell
docker compose up
```

This will create all of the local directories necessary. On your host machine (not from inside the container) you can sort your ROMs into the correct directories like this:

=== ":simple-windowsxp: Windows"

```batch
igir copy zip test clean ^
--dat "No-Intro*.zip" ^
--input "ROMs\" ^
--output "romm\roms\{romm}"
```

=== ":simple-apple: macOS"

```shell
igir copy zip test clean \
--dat "No-Intro*.zip" \
--input "ROMs/" \
--output "romm/roms/{romm}"
```

=== ":simple-linux: Linux"

```shell
igir copy zip test clean \
--dat "No-Intro*.zip" \
--input "ROMs/" \
--output "romm/roms/{romm}"
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ nav:
- usage/desktop/retroarch.md
- usage/desktop/retrodeck.md
- usage/desktop/retropie.md
- usage/desktop/romm.md
- usage/handheld/twmenu.md
- FPGA:
- usage/hardware/mister.md
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "igir",
"version": "2.6.1",
"version": "2.6.2",
"description": "🕹 A video game ROM collection manager to help filter, sort, patch, archive, and report on collections on any OS.",
"keywords": [
"1g1r",
Expand Down
21 changes: 17 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,22 @@ process.once('beforeExit', async () => {
});
});

const GLOBAL_CACHE_DIR = path.resolve(ROOT_DIR).startsWith(os.tmpdir())
? os.homedir()
: ROOT_DIR;
const GLOBAL_CACHE_FILE = [
path.resolve(ROOT_DIR),
os.homedir(),
process.cwd(),
]
.filter((dir) => dir && !dir.startsWith(os.tmpdir()))
.map((dir) => path.join(dir, `${COMMAND_NAME}.cache`))
.sort((a, b) => (fs.existsSync(a) ? 1 : 0) - (fs.existsSync(b) ? 1 : 0))
.find((file) => {
try {
fsPoly.touchSync(file);
return true;
} catch {
return false;
}
});

/**
* A static class of constants that are determined at startup, to be used widely.
Expand All @@ -62,7 +75,7 @@ export default class Constants {

static readonly GLOBAL_TEMP_DIR = GLOBAL_TEMP_DIR;

static readonly GLOBAL_CACHE_FILE = path.join(GLOBAL_CACHE_DIR, `${COMMAND_NAME}.cache`);
static readonly GLOBAL_CACHE_FILE = GLOBAL_CACHE_FILE;

/**
* A reasonable max of filesystem threads for operations such as:
Expand Down
1 change: 1 addition & 0 deletions src/modules/argumentsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ Advanced usage:
{onion} The ROM's emulator-specific /Roms/* directory for OnionOS/GarlicOS (e.g. "GB")
{pocket} The ROM's core-specific /Assets/* directory for the Analogue Pocket (e.g. "gb")
{retrodeck} The ROM's emulator-specific /roms/* directory for the 'RetroDECK' image (e.g. "gb")
{romm} The ROM's manager-specific /roms/* directory for 'RomM' (e.g. "gb")
{twmenu} The ROM's emulator-specific /roms/* directory for TWiLightMenu++ on the DSi/3DS (e.g. "gb")
Example use cases:
Expand Down
16 changes: 16 additions & 0 deletions src/polyfill/fsPoly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,22 @@ export default class FsPoly {
await util.promisify(fs.close)(file);
}

static touchSync(filePath: string): void {
const dirname = path.dirname(filePath);
if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname, { recursive: true });
}

// Create the file if it doesn't already exist
const file = fs.openSync(filePath, 'a');

// Ensure the file's `atime` and `mtime` are updated
const date = new Date();
fs.futimesSync(file, date, date);

fs.closeSync(file);
}

static async walk(pathLike: PathLike, callback?: FsWalkCallback): Promise<string[]> {
let output: string[] = [];

Expand Down
24 changes: 13 additions & 11 deletions src/types/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,19 @@ export default class Cache<V> {
return this;
}

const cacheData = JSON.parse(
await util.promisify(fs.readFile)(this.filePath, { encoding: Cache.BUFFER_ENCODING }),
) as CacheData;
const compressed = Buffer.from(cacheData.data, Cache.BUFFER_ENCODING);
const decompressed = await util.promisify(zlib.inflate)(compressed);
const keyValuesObject = JSON.parse(decompressed.toString(Cache.BUFFER_ENCODING));
const keyValuesEntries = Object.entries(keyValuesObject) as [string, V][];
this.keyValues = new Map(keyValuesEntries);
if (this.maxSize !== undefined) {
this.keyOrder = new Set(Object.keys(keyValuesObject));
}
try {
const cacheData = JSON.parse(
await util.promisify(fs.readFile)(this.filePath, { encoding: Cache.BUFFER_ENCODING }),
) as CacheData;
const compressed = Buffer.from(cacheData.data, Cache.BUFFER_ENCODING);
const decompressed = await util.promisify(zlib.inflate)(compressed);
const keyValuesObject = JSON.parse(decompressed.toString(Cache.BUFFER_ENCODING));
const keyValuesEntries = Object.entries(keyValuesObject) as [string, V][];
this.keyValues = new Map(keyValuesEntries);
if (this.maxSize !== undefined) {
this.keyOrder = new Set(Object.keys(keyValuesObject));
}
} catch { /* empty */ }

return this;
}
Expand Down
Loading

0 comments on commit c2a07c5

Please sign in to comment.