Skip to content

Commit

Permalink
Refactor: Created GetfullPath
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverGeneser committed Dec 5, 2023
1 parent e60dd7b commit 889dbd9
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions servers/lib/src/files/services/local-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ export default class LocalFilesService implements IFilesService {
// eslint-disable-next-line no-useless-constructor, no-empty-function
constructor(private configService: ConfigService) {}

async listDirectory(path: string): Promise<Project> {
GetFullPath(path: string) {
const dataPath = this.configService.get('LOCAL_PATH');
const pathParts = path.split('/');
const fullPath =
pathParts[0] === this.configService.get('GITLAB_GROUP')
? join(dataPath, pathParts.splice(1).join('/'))
: join(dataPath, pathParts.join('/'));
return pathParts[0] === this.configService.get('GITLAB_GROUP')
? join(dataPath, pathParts.splice(1).join('/'))
: join(dataPath, pathParts.join('/'));
}

async listDirectory(path: string): Promise<Project> {
const fullPath = this.GetFullPath(path);

const files = await fs.promises.readdir(fullPath);

Expand All @@ -37,12 +40,7 @@ export default class LocalFilesService implements IFilesService {
}

async readFile(path: string): Promise<Project> {
const dataPath = this.configService.get('LOCAL_PATH');
const pathParts = path.split('/');
const fullPath =
pathParts[0] === this.configService.get('GITLAB_GROUP')
? join(dataPath, pathParts.splice(1).join('/'))
: join(dataPath, pathParts.join('/'));
const fullPath = this.GetFullPath(path);

try {
const content = await (
Expand Down

0 comments on commit 889dbd9

Please sign in to comment.