mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feature-136] Add model types icons + export models + init delete models + init searchbar
This commit is contained in:
@@ -12,14 +12,16 @@ import { RequestService } from "../request.service";
|
||||
import { copyFileSync } from "fs-extra";
|
||||
import sanitize from "sanitize-filename";
|
||||
import { Progression, ensureFolderExist } from "../../helpers/fs.helpers";
|
||||
import { MODEL_FILE_EXTENSIONS, MODEL_TYPE_FOLDERS } from "../../../shared/models/models/constants";
|
||||
import { MODEL_FILE_EXTENSIONS, MODEL_TYPES, MODEL_TYPE_FOLDERS } from "../../../shared/models/models/constants";
|
||||
import { InstallationLocationService } from "../installation-location.service";
|
||||
import { Observable } from "rxjs";
|
||||
import { Observable, lastValueFrom } from "rxjs";
|
||||
import { readdir } from "fs/promises";
|
||||
import md5File from "md5-file";
|
||||
import { allSettled } from "../../../shared/helpers/promise.helpers";
|
||||
import { ModelSaberService } from "../thrid-party/model-saber/model-saber.service";
|
||||
import { BsmLocalModel } from "shared/models/models/bsm-local-model.interface";
|
||||
import { ArchiveProgress } from "shared/models/archive.interface";
|
||||
import { Archive } from "../../models/archive.class";
|
||||
|
||||
export class LocalModelsManagerService {
|
||||
|
||||
@@ -145,7 +147,7 @@ export class LocalModelsManagerService {
|
||||
|
||||
const localModel: BsmLocalModel = {
|
||||
path: modelPath,
|
||||
fileName: path.basename(modelPath),
|
||||
fileName: path.basename(modelPath, MODEL_FILE_EXTENSIONS[type]),
|
||||
model: await this.modelSaber.getModelByHash(hash),
|
||||
type, hash
|
||||
}
|
||||
@@ -165,6 +167,20 @@ export class LocalModelsManagerService {
|
||||
|
||||
}
|
||||
|
||||
public async exportModels(output: string, version?: BSVersion, models?: BsmLocalModel[]): Promise<Observable<ArchiveProgress>>{
|
||||
const archive = new Archive(output);
|
||||
if(models?.length){
|
||||
models.forEach(model => archive.addFile(model.path));
|
||||
}
|
||||
else{
|
||||
for(const type of MODEL_TYPES){
|
||||
archive.addDirectory(await this.getModelFolderPath(type, version));
|
||||
}
|
||||
}
|
||||
|
||||
return archive.finalize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enableDeepLinks(): boolean{
|
||||
|
||||
Reference in New Issue
Block a user