orhun / rustypaste

A minimal file upload/pastebin service.
https://blog.orhun.dev/blazingly-fast-file-sharing
MIT License
757 stars 47 forks source link

fix(upload): error on upload with the same filename #258

Closed tessus closed 5 months ago

tessus commented 5 months ago

Description

Currently it is possible to upload files with the same name. This is undefined behavior. e.g. which file should be returned when accessing it?

To solve this problem this change introduces a check whether a file (that hasn't expired) alredy exists with the same name. If so, an error will be returned.

Motivation and Context

see https://github.com/orhun/rustypaste/discussions/241

I am opening this PR now, because I want to check, whether the test that fails in #246 also fails with this one.

Depending on which PR is merged first, a change will be required to add an .await to the glob_match_file call.

How Has This Been Tested?

Changelog Entry

### Changed

- Return an error when a file with the same name already exists on the server

Types of Changes

Checklist:

codecov-commenter commented 5 months ago

Codecov Report

Attention: Patch coverage is 83.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 70.21%. Comparing base (fa5105d) to head (1266766).

Files Patch % Lines
src/paste.rs 83.33% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #258 +/- ## ========================================== + Coverage 70.09% 70.21% +0.12% ========================================== Files 11 11 Lines 632 638 +6 ========================================== + Hits 443 448 +5 - Misses 189 190 +1 ``` | [Flag](https://app.codecov.io/gh/orhun/rustypaste/pull/258/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Orhun+Parmaks%C4%B1z) | Coverage Δ | | |---|---|---| | [unit-tests](https://app.codecov.io/gh/orhun/rustypaste/pull/258/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Orhun+Parmaks%C4%B1z) | `70.21% <83.33%> (+0.12%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Orhun+Parmaks%C4%B1z#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.