Skip to content

Commit

Permalink
feat: 10번 채점 로직 구현 및 isDirecotryExist 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
flydog98 authored and LuizyHub committed Dec 1, 2023
1 parent b1ec48a commit 4bfedbf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/backend/src/quiz-wizard/magic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ export class Magic {

async isDirectoryExist(container: string, path: string): Promise<boolean> {
const { stdoutData } = await this.sshService.executeSSHCommand(
`docker exec -w /home/quizzer/quiz/ -u quizzer ${container} ls -l ${path} | grep ^d`,
`docker exec -w /home/quizzer/quiz/ -u quizzer ${container} ls -la | grep '^d.* ${path}$'`,
);

return stdoutData !== '';
}

async isFileExist(container: string, path: string): Promise<boolean> {
const { stdoutData } = await this.sshService.executeSSHCommand(
`docker exec -w /home/quizzer/quiz/ -u quizzer ${container} ls | grep '^${path}$'`,
);

return stdoutData !== '';
Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/quiz-wizard/quiz-wizard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class QuizWizardService {
7: (containerId: string) => this.checkCondition7(containerId),
8: (containerId: string) => this.checkCondition8(containerId),
9: (containerId: string) => this.checkCondition9(containerId),
10: (containerId: string) => this.checkCondition10(containerId),
};

async submit(containerId: string, quizId: number) {
Expand Down Expand Up @@ -146,4 +147,18 @@ index e69de29..3b18e51 100644
'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'
);
}

async checkCondition10(containerId: string): Promise<boolean> {
if (await this.magic.isFileExist(containerId, 'tmp.js')) {
return false;
}
if (await this.magic.isFileExist(containerId, 'tmptmp.js')) {
return false;
}
if (await this.magic.isFileExist(containerId, 'tmptmptmp.js')) {
return false;
}

return true;
}
}

0 comments on commit 4bfedbf

Please sign in to comment.