Ignore album art and info files
This commit is contained in:
parent
ba92da313b
commit
76f25ac199
@ -212,7 +212,7 @@ class MusicLibrary implements Initialisable
|
||||
{
|
||||
this.#logger.info('Starting library scan');
|
||||
const start = Date.now();
|
||||
const filePaths = Util.readdirRecursive(this.#path);
|
||||
const filePaths = Util.readdirRecursive(this.#path, { ignoreSuffixes: [ '.nfo', '.jpg', '.jpeg', '.png' ] });
|
||||
this.#logger.debug(`${filePaths.length} files to go through`);
|
||||
if (!this.#index.size)
|
||||
this.#logger.info('No index built, performing first time scan. This may take some time depending on the size of your music library');
|
||||
|
@ -16,6 +16,7 @@ import { PlainError } from '../../@types/Shared.js';
|
||||
import { DiscordBaseStruct } from '../../@types/DiscordClient.js';
|
||||
|
||||
export type StringIndexable<T = unknown> = { [key: string]: T };
|
||||
type ReaddirOpts = { ignoreDotfiles?: boolean, ignoreSuffixes?: string[] };
|
||||
|
||||
const Constants: {
|
||||
QuotePairs: StringIndexable<string>
|
||||
@ -213,11 +214,13 @@ class Util
|
||||
* Read directory recursively and return all file paths
|
||||
* @static
|
||||
* @param {string} directory Full path to target directory
|
||||
* @param {boolean} [ignoreDotfiles=true]
|
||||
* @param {{ ignoreDotfiles?: boolean; }} opts
|
||||
* @param {boolean} [opts.ignoreDotfiles=true]
|
||||
* @param {string[]} [opts.ignoreSuffixes=[]]
|
||||
* @return {string[]} Array with the paths to the files within the directory
|
||||
* @memberof Util
|
||||
*/
|
||||
static readdirRecursive (dir: string, ignoreDotfiles = true)
|
||||
static readdirRecursive (dir: string, { ignoreDotfiles = true, ignoreSuffixes = [] }: ReaddirOpts = {})
|
||||
{
|
||||
const result = [];
|
||||
(function read (directory: string)
|
||||
@ -227,6 +230,8 @@ class Util
|
||||
{
|
||||
if (file.startsWith('.') && ignoreDotfiles)
|
||||
continue;
|
||||
if (ignoreSuffixes.some(suf => file.endsWith(suf)))
|
||||
continue;
|
||||
const filePath = path.join(directory, file);
|
||||
|
||||
if (fs.statSync(filePath).isDirectory())
|
||||
|
Loading…
Reference in New Issue
Block a user