1
0
Fork 0
This commit is contained in:
lightling 2024-02-28 18:42:50 -05:00
parent a20a20b3ce
commit d36a0a8253
2 changed files with 2 additions and 49 deletions

View file

@ -7,19 +7,9 @@ This repo uses its own `config.json` in order to save media in the same format a
## Scripts ## Scripts
### `node run-initDb.js`
Initializes a user database from existing folders. Useful if you have a pre-existing archive of users.
Args:
- `--path={/path/to/your/archive}`
Example:
- `node run-initDb.js --path=/mnt/data/archive` will read all child directories in `/mnt/data/archive` (e.g. `/mnt/data/archive/userA`, `/mnt/data/archive/userB`, etc.) and create a `db.json` file in `/mnt/data/archive` listing the users.
### `node run-downloadDb.js` ### `node run-downloadDb.js`
Runs a full download of all users listed in the db.json of the archive (the provided `--path`). Runs a full download of all users listed in the db.json of the archive (the provided `--path`). If db.json is not present, one will be created.
Args: Args:
- `--path={/path/to/your/archive}` - `--path={/path/to/your/archive}`
@ -31,7 +21,7 @@ Example:
### `run-downloadUsers.js` ### `run-downloadUsers.js`
Should add a new user to the db and initiate a full download similar to `run-downloadDb.js` Adds new user(s) to the db and initiate a full download similar to `run-downloadDb.js`. If db.json is not present, one will be created.
Args: Args:
- `--path={/path/to/your/archive}` - `--path={/path/to/your/archive}`
@ -67,16 +57,6 @@ Additional args to pass to gallery-dl. See [gallery-dl CLI options](https://gith
## TODO ## TODO
### `run-updateDb.js`
Should pull from the user database and update the archive without doing a full download. The DB should save with a lastUpdated field. This should be used as a date for the `/search` API. Preferred if it's been a long time since an update has happened for a user and/or the user has uploaded a significant amount of media since lastUpdated.
Note: if you've updated the DB recently, it may be more performant to run `node run-downloadDb.js` with `--args="-A {#}"` to simply run the `/media` check instead of the `/search` check, where `-A` will abort the user after `{#}` tries.
Args:
- `--path={/path/to/your/archive}`
- `--threads={#}`
- `--args={gallery-dl args}`
### `run-renameUser.js` ### `run-renameUser.js`
Should rename an existing user in the db, optionally renaming their existing archive and its contents if `--full=true`. Should rename an existing user in the db, optionally renaming their existing archive and its contents if `--full=true`.
@ -87,7 +67,3 @@ Args:
- `--full={true|false}` - `--full={true|false}`
- `--path={/path/to/your/archive}` - `--path={/path/to/your/archive}`
- `--args={gallery-dl args}` - `--args={gallery-dl args}`
### Rename Detection
Should detect renames when running `/search`. Occasionally `/media` will fail due to the rename, but `/search` will return results, causing a full download from `/search` and adding the user to the db without notice. This should stop the download and print out an error that they've been updated from `username` to `username`. Because the command will have already finished `/media` and thus be halfway through the process, this should be done manually after the command has finished.

View file

@ -1,23 +0,0 @@
import { getArg } from './lib/args.js';
import { createDb } from './lib/schema.js';
import { error } from './lib/log.js';
const ctx = 'initDb.js';
/**
* Initializes a user db from a list of existing directories
* at the specified `--path` parameter when executing the command.
* Useful when there is already a collection of folders.
*/
export const initDb = async () => {
let directory = '';
try {
directory = getArg('path');
} catch (err) {
error(ctx, err);
return;
}
createDb();
};
initDb();