mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
fix: delete files when deleting share manually
This commit is contained in:
parent
0823d28e23
commit
ffd538f140
2 changed files with 6 additions and 5 deletions
|
@ -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],
|
||||
|
|
|
@ -11,6 +11,7 @@ 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";
|
||||
|
||||
|
@ -18,7 +19,7 @@ import { CreateShareDTO } from "./dto/createShare.dto";
|
|||
export class ShareService {
|
||||
constructor(
|
||||
private prisma: PrismaService,
|
||||
|
||||
private fileService: FileService,
|
||||
private config: ConfigService,
|
||||
private jwtService: JwtService
|
||||
) {}
|
||||
|
@ -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 } });
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue