Skip to content

Commit

Permalink
fix (artifact): database entries of artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Nov 6, 2021
1 parent b8194f1 commit 4682933
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/adonisjs/app/Controllers/Http/v1/CaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,26 +274,16 @@ class CaseController {
.where('case_id', c.id)
.delete()

let _caseArtifacts = Database
let _caseArtifacts = await Database
.from('case_artifacts')
.where('case_id', c.id)
.select('artifact_id')
await c.artifacts().delete()

// await c.users().detach()
// await c.quests().detach()
let _artifacts = await Database
.from('artifacts')
.whereIn('id', _caseArtifacts)
for (let i = 0; i < _caseArtifacts.length; i++) {
let artifact = await Artifact.find(_caseArtifacts[i].id)
for (let i in _caseArtifacts) {
let artifact = await Artifact.find(_caseArtifacts[i].artifact_id)
await artifact.delete()
}
let relativeP = ''
for (let i = 0; i < _artifacts.length; i++) {
let path = Helpers.publicPath(_artifacts[i].relative_path)
Drive.delete(path)
}

console.log('================= deleting the directory')
let dir_delete = Helpers.publicPath('/resources/artifacts/cases/') + c.id
Expand Down

0 comments on commit 4682933

Please sign in to comment.