Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete file if exist before uploading another one #50

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Turn0xx
Copy link
Contributor

@Turn0xx Turn0xx commented Oct 29, 2024

-I couldn't do this with one query because MySql doesn't support RETURNING clause
-For retriveal tests I had to build a clean state for them to work because they were depending on Upload tests

Issue: #38

Checklist

-I couldn't do this with one query because MySql doesn't support
RETURNING clause
-For retriveal tests I had to build a clean state for them to work
because they were depending on Upload tests
src/plugins/custom/file-handling.ts Outdated Show resolved Hide resolved
src/plugins/custom/file-handling.ts Outdated Show resolved Hide resolved
src/plugins/custom/file-handling.ts Outdated Show resolved Hide resolved
src/plugins/custom/file-handling.ts Outdated Show resolved Hide resolved
test/routes/api/tasks/tasks.test.ts Outdated Show resolved Hide resolved
@jean-michelet
Copy link
Contributor

jean-michelet commented Nov 2, 2024 via email

Copy link
Contributor

@jean-michelet jean-michelet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at my feedbacks plz.

Besides that, LGTM!

src/plugins/custom/file-handling.ts Outdated Show resolved Hide resolved
src/routes/api/tasks/index.ts Outdated Show resolved Hide resolved
test/routes/api/tasks/tasks.test.ts Outdated Show resolved Hide resolved
- Generalize setup and tear down for all tasks image tests describe
blocks
- In replacing image upload test, assert that the old file is really
removed and the new file is persisted
Copy link

sonarcloud bot commented Nov 3, 2024

@jean-michelet
Copy link
Contributor

Can I merge @climba03003 @Fdawgs?

Copy link
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for temporary file approach.

  1. Save the file with random name.
  2. Remove the old file.
  3. Move the tmp file to proper location.

It can ensure when the transaction is rollback or file upload is failed.
You still have the copy of old file.

@jean-michelet
Copy link
Contributor

Do you plan to terminate this PR @Turn0xx? Or should I terminate it for you?

@Turn0xx
Copy link
Contributor Author

Turn0xx commented Nov 26, 2024

@jean-michelet I plan to finish it, but i don't have much time this weeks so i don't know when.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants