Skip to content

Commit

Permalink
fix: delete files when deleting share manually
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Oct 11, 2022
1 parent 0823d28 commit ffd538f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions backend/src/share/share.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Module } from "@nestjs/common";
import { JwtModule, JwtService } from "@nestjs/jwt";
import { AuthModule } from "src/auth/auth.module";
import { forwardRef, Module } from "@nestjs/common";
import { JwtModule } from "@nestjs/jwt";
import { FileModule } from "src/file/file.module";
import { ShareController } from "./share.controller";
import { ShareService } from "./share.service";

@Module({
imports: [JwtModule.register({})],
imports: [JwtModule.register({}), forwardRef(() => FileModule)],
controllers: [ShareController],
providers: [ShareService],
exports: [ShareService],
Expand Down
4 changes: 3 additions & 1 deletion backend/src/share/share.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import * as archiver from "archiver";
import * as argon from "argon2";
import * as fs from "fs";
import * as moment from "moment";
import { FileService } from "src/file/file.service";
import { PrismaService } from "src/prisma/prisma.service";
import { CreateShareDTO } from "./dto/createShare.dto";

@Injectable()
export class ShareService {
constructor(
private prisma: PrismaService,

private fileService: FileService,
private config: ConfigService,
private jwtService: JwtService
) {}
Expand Down Expand Up @@ -139,6 +140,7 @@ export class ShareService {

if (!share) throw new NotFoundException("Share not found");

await this.fileService.deleteAllFiles(shareId);
await this.prisma.share.delete({ where: { id: shareId } });
}

Expand Down

0 comments on commit ffd538f

Please sign in to comment.