feat: Add check to prevent favorited files from being deleted (#369)

* additions

* add proper lock system

* migreation

* Revert "migreation"

This reverts commit 4058146c2867d8a0cf2edc56b89e4bec3b2a826b.

* remove that

* get rid of bad code

---------

Co-authored-by: Jayvin Hernandez <gogojayvin923@gmail.com>
This commit is contained in:
IThundxr 2023-04-12 19:59:30 -04:00 committed by GitHub
parent fd2746c2d0
commit d238e24f62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View file

@ -1,7 +1,7 @@
blank_issues_enabled: false blank_issues_enabled: false
contact_links: contact_links:
- name: Feature Request - name: Feature Request
url: https://github.com/diced/zipline/discussions/new?category=ideas&title=Your%20breif%20description%20here&labels=feature url: https://github.com/diced/zipline/discussions/new?category=ideas&title=Your%20brief%20description%20here&labels=feature
about: Ask for a new feature about: Ask for a new feature
- name: Zipline Discord - name: Zipline Discord
url: https://discord.gg/EAhCRfGxCF url: https://discord.gg/EAhCRfGxCF

View file

@ -14,7 +14,7 @@ Create an issue on GitHub, please include the following (if one of them is not a
Create an discussion on GitHub, please include the following: Create an discussion on GitHub, please include the following:
- Breif explanation of the feature in the title (very breif please) - Brief explanation of the feature in the title (very brief please)
- How it would work (detailed, but optional) - How it would work (detailed, but optional)
## Pull Requests (contributions to the codebase) ## Pull Requests (contributions to the codebase)

View file

@ -7,6 +7,7 @@ function preFileDecorator(fastify: FastifyInstance, _, done) {
done(); done();
async function preFile(this: FastifyReply, file: File) { async function preFile(this: FastifyReply, file: File) {
if (file.favorite) return false;
if (file.expiresAt && file.expiresAt < new Date()) { if (file.expiresAt && file.expiresAt < new Date()) {
await this.server.datasource.delete(file.name); await this.server.datasource.delete(file.name);
await this.server.prisma.file.delete({ where: { id: file.id } }); await this.server.prisma.file.delete({ where: { id: file.id } });