Commit Graph

31 Commits

Author SHA1 Message Date
Helmut K. C. Tessarek 4774de6652
refactor(server): use more specific HTTP status codes (#262)
* refactor(server): use more specific http status codes

* fix: clippy error - oops missed that one

* test(fixtures): add check for status code
2024-03-11 14:00:45 +01:00
Helmut K. C. Tessarek 4987cfe5e5
fix(upload): error on upload with the same filename (#258) 2024-03-08 14:47:13 +01:00
Helmut K. C. Tessarek fa5105deab
test(upload): update the hash of the example file (#254)
changed at source
2024-03-06 05:57:59 +01:00
Jake Howard dae00c42b5
feat(server): do path joins more safely (#247)
* Do path joins more safely

* Improve path cleaning and tests

* Lower-case error message

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Correct handle potential errors in `get_path`

* Use `expect` in tests, rather than `unwrap`

* Correctly handle invalid upload path without panic

* Correctly handle filesystem create errors

* Use result rather than option to allow easier error handling

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2024-03-06 05:55:59 +01:00
Helmut K. C. Tessarek db971e6434
feat(server): allow to override filename when using random_url (#233)
* feat(server): allow to override filename when using random_url

* docs(README): remove line from features

* refactor(header): make const private
2024-02-12 13:06:12 +01:00
dependabot[bot] a291307bec
chore(deps): bump byte-unit from 4.0.19 to 5.0.3 (#192)
* chore(deps): bump byte-unit from 4.0.19 to 5.0.3

Bumps [byte-unit](https://github.com/magiclen/byte-unit) from 4.0.19 to 5.0.3.
- [Commits](https://github.com/magiclen/byte-unit/compare/v4.0.19...v5.0.3)

---
updated-dependencies:
- dependency-name: byte-unit
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(deps): update codebase accordingly to the new version of byte-unit

* fix(fixtures): use more precise byte comparison

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-12-05 13:08:22 +01:00
Ömer Üstün 95379c9f66
feat(server): support handling spaces in filenames (#107)
* feat(server): add url encoding

- Introduced an option to enable encoding for filenames in the returned URL.
- Modified the encoding approach to specifically target whitespaces, replacing them with `%20`.
- Included unit tests to validate this encoding approach.
- Added fixture tests for broader functional verification.
- Removed the `urlencoding` dependency from `Cargo.toml`.

* Refactor code and fixtures for better compliance and consistency

- Fixed errors in the fixture configuration to ensure tests run as expected.
- Reformatted line endings for consistency across the codebase.
- Made necessary adjustments to adhere to Clippy's recommendations.

* Enhance whitespace handling options for filenames

- Implemented a configuration choice for space handling in filenames: encode, replace with underscores or none.
- Added corresponding unit and fixture tests.

* Remove redundant function call

Fixed misplaced line as per @tessus's review feedback, preventing duplicate handling of spaces in filenames.

* Delete test file with spaces.txt

* Refactor filename space handling

- Introduced `SpaceHandling` enum to manage filename spaces.
- Updated server.rs and paste.rs to utilize the new method.
- Added unit tests for the new filename handling method.
- Adjusted fixture tests to reflect these changes.

* Move filename processing into `SpaceHandling` enum

- Relocated filename processing logic to reside within the `SpaceHandling` enum, enhancing encapsulation.
- Updated calls in `server.rs` and `paste.rs` to use the new method structure.
- Adjusted unit tests to align with the refactored function location and call pattern.

* Refactor based on review suggestions

- Incorporated the inline suggestions made by @tessus, removing the unnecessary one-line assignments.
- Ensured the code adheres to Rust guidelines by running clippy and fmt.

* chore(deps): revert changes in Cargo.lock

* chore(config): replace spaces as default

* refactor(config): move SpaceHandling to config module

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-08-26 14:35:13 +02:00
Helmut K. C. Tessarek d2d07ad345
feat(server): improve random_url config handling (#122)
* feat(server): improve random_url config handling

* log deprecation warnings after hot reload of config

* refactor(config): adjust config files

* tests(config): add test for deprecation codepath

* remove unnecessary to_string()

* style: delete empty line

* refactor(server): clean up random_url config handling

* refactor(config): update configs accordingly to deprecated random_url.enabled

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-08-20 20:32:41 +02:00
Helmut K. C. Tessarek 62bbfef6a3
feat(server): add random suffix mode (#69)
* add random suffix mode

* fix linter issues

* add test case

* fix linter issues

* add comments, remove empty lines and single line declarations

* more test cases

* refactor(config): rename suffix_mode to random_suffix

* refactor(paste): clean up the random suffix logic

* chore(config): add random suffix example to default config

* docs(readme): mention random suffix feature

* test(fixtures): add fixture test for random suffix mode

* random_suffix -> suffix_mode

* fix default extension for .dotfile w/o extension

* fix formatting

* style(format): fix the indentation for random suffix fixture

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-07-01 00:11:16 +02:00
Rahul Garg bd88146430
feat(server): support one shot URLs (#46)
* Add support for OneshotUrl

* Review cmt: Update README

* docs(oneshot): update documentation about oneshot URLs

* Review cmt: revert fmt

* test(fixtures): add fixture test for oneshot URLs

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-05-28 22:09:14 +02:00
Orhun Parmaksız 8bac3cc91f
fix(lints): apply clippy suggestions for tests 2022-12-18 23:43:58 +03:00
Orhun Parmaksız e83b8e6f4a
fix(lints): apply clippy suggestions 2022-12-18 23:12:28 +03:00
Orhun Parmaksız 1e1da30b83
fix(lints): apply clippy suggestions 2022-08-14 12:11:03 +02:00
Orhun Parmaksız 1f8f462299
test(server): add tests for different paste types 2022-05-17 22:09:24 +03:00
Orhun Parmaksız a330b59dca
fix(lints): apply clippy suggestions for tests 2022-05-16 12:58:41 +03:00
Orhun Parmaksız 657ca8c1d4
fix(server): do not hold the RwLock guard before async calls 2022-05-16 12:34:57 +03:00
Orhun Parmaksız c48e45d68c
chore(deps): upgrade actix dependencies
closes #18
2022-03-17 15:46:32 +03:00
Orhun Parmaksız 6f1dcab15a
fix(lints): apply clippy suggestions 2022-02-24 23:54:54 +03:00
Orhun Parmaksız ebbe8dbfae
test(paste): update paste test about borrowing the config 2021-12-05 15:27:38 +03:00
Orhun Parmaksız 8f3f89716f
fix(async): drop the RW guard of config before suspend points 2021-12-05 15:03:51 +03:00
Orhun Parmaksız 6b3914a54e
chore(lib): import required traits for backwards edition compatibility 2021-11-07 16:25:08 +03:00
Orhun Parmaksız f078a9afa7
fix(server): prevent serving an already expired file 2021-11-07 00:49:31 +03:00
Orhun Parmaksız 3eee294bd9
docs(lib): update the function comment for store_remote_file 2021-11-07 00:01:30 +03:00
Orhun Parmaksız 7a6842e181
feat(paste): support pasting files from remote URLs 2021-11-06 23:55:55 +03:00
orhun 13126e79ce
refactor(paste): use timestamp for expiring one shot files 2021-08-27 16:05:40 +03:00
orhun 92c35fe6df
feat(paste): support setting an expiry date for uploads 2021-08-27 15:54:23 +03:00
orhun 73359f3534
feat(paste): support disappearing (oneshot) files 2021-08-26 22:57:46 +03:00
orhun 3223c6379c
refactor(paste): associate directories with the paste types 2021-08-26 21:09:33 +03:00
orhun cc385d1aca
refactor(test): use `tests` module for tests 2021-08-09 22:50:01 +03:00
orhun e7ad855f4d
feat(paste): support blacklisting MIME types 2021-08-09 22:48:51 +03:00
orhun f3855be2c9
feat(paste): support shortening URLs 2021-08-04 17:35:54 +03:00