mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Rewrote image route generation system
This commit is contained in:
parent
ae0e271957
commit
97d1343385
@ -1,3 +1,4 @@
|
|||||||
|
import path from "node:path";
|
||||||
import { ProgramStatics } from "@spt/ProgramStatics";
|
import { ProgramStatics } from "@spt/ProgramStatics";
|
||||||
import { OnLoad } from "@spt/di/OnLoad";
|
import { OnLoad } from "@spt/di/OnLoad";
|
||||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||||
@ -71,17 +72,7 @@ export class DatabaseImporter implements OnLoad {
|
|||||||
await this.hydrateDatabase(this.filepath);
|
await this.hydrateDatabase(this.filepath);
|
||||||
|
|
||||||
const imageFilePath = `${this.filepath}images/`;
|
const imageFilePath = `${this.filepath}images/`;
|
||||||
const directories = await this.fileSystem.getDirectories(imageFilePath);
|
await this.createRouteMappingAsync(imageFilePath, "files");
|
||||||
await this.loadImagesAsync(imageFilePath, directories, [
|
|
||||||
"/files/achievement/",
|
|
||||||
"/files/CONTENT/banners/",
|
|
||||||
"/files/handbook/",
|
|
||||||
"/files/Hideout/",
|
|
||||||
"/files/launcher/",
|
|
||||||
"/files/prestige/",
|
|
||||||
"/files/quest/icon/",
|
|
||||||
"/files/trader/avatar/",
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,6 +130,7 @@ export class DatabaseImporter implements OnLoad {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @deprecated
|
||||||
* Find and map files with image router inside a designated path
|
* Find and map files with image router inside a designated path
|
||||||
* @param filepath Path to find files in
|
* @param filepath Path to find files in
|
||||||
*/
|
*/
|
||||||
@ -166,6 +158,21 @@ export class DatabaseImporter implements OnLoad {
|
|||||||
this.imageRouter.addRoute("/favicon.ico", `${filepath}icon.ico`);
|
this.imageRouter.addRoute("/favicon.ico", `${filepath}icon.ico`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add routes into imageRouter
|
||||||
|
* @param directory Directory with files to add to router
|
||||||
|
* @param newBasePath new starting path
|
||||||
|
*/
|
||||||
|
public async createRouteMappingAsync(directory: string, newBasePath: string): Promise<void> {
|
||||||
|
const directoryContent = await this.fileSystem.getFiles(directory, true);
|
||||||
|
|
||||||
|
for (const fileNameWithPath of directoryContent) {
|
||||||
|
const bsgPath = `/${newBasePath}/${FileSystem.stripExtension(fileNameWithPath)}`;
|
||||||
|
const sptPath = `${directory}${fileNameWithPath}`;
|
||||||
|
this.imageRouter.addRoute(bsgPath, sptPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for a path override in the http json config file
|
* Check for a path override in the http json config file
|
||||||
* @param imagePath Key
|
* @param imagePath Key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user