-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
File & directory deletion feature #1093
base: master
Are you sure you want to change the base?
Conversation
Lines 329 to 330 in 82dd826
I am curious why the upload feature is implemented like so. I guess it's good for unforeseen future extensibility, but there is semantic duplication between the The real question I want to ask, is should I implement the deletion feature in a similar manner? I.e. something like this: app.service(web::resource("/delete").route(web::delete().to(file_rm::rm_file))); |
Are you suggesting it might have been better to just have I see how this is a bit of a conundrum with delete. I also want to add WebDAV at some point and that will introduce even more semantics. Perhaps it's the best to go with what you suggested just now and eat the semantic duplication for the time being. It's not like it can't be changed later. |
Hi, unfortunately I can't directly help... just wanted to say that I appreciate the effort and if it gets done at some point, my life would be somehow better :) |
Thanks for reminding me. I have too many things on hand and honestly just forgot about this whole matter. I will find some time to work on it this week, hopefully. |
Rebased on #1331. |
Rebased on |
Rebased on |
Could you add some tests? Since this is going to be deleting things, it needs some proper tests. |
Yeah I'm working on that on and off. The tests are actually written but several are failing. My original intention was to combine the tests and the fixes into one commit, but I guess there's no harm in splitting them up. I'll push the tests first and then look to fix them. |
If you can spare some time, please take a look at the test suite; make sure they are testing the correct behaviour. Thanks. |
No worries. There's no rush to get this in. Just take your time and make sure things look good.
I will try to squeeze a review in but no promises, I'm fairly low on time currently. |
Rebased on #1454. |
This should be ready now, finally. Everything works as expected, as far as I can tell. But you may wish to merge the other PR first. |
Needs a rebase and then I will do a proper review. :) |
Actually, let me do an interactive rebase to reorganise things. Then it'd be a bit tidier. |
This allows the encoding set definitions to be `include!`ed into integration tests
hey, how's the feature going? |
Implementation is complete. Just waiting on review. @svenstaro You got time to take a look? |
I will take some time. Might take a look on the weekend. |
Hi Sven, please don't forget about this one 😅 |
Sorry, reviewing now. |
Thoughts:
|
Good points.
That would be nice. I would also want a toggle/checkbox that allows turning off confirmation, in case where you want to delete several things en-mass. I'll give this a shot, but I'm not great at front end coding. We'll see.
I think there's some misunderstanding. The paths accepted by
So I believe the implementation needs no changes, but it would be prudent to note this in the CLI help document though. I'll make that happen. Also it might be a good idea to log a message at
Oh I actually didn't know we support serving a single file. That's a nice feature. Hmm yeah this is very interesting indeed. Because the semantics of But first of all, should we allow removing (or for And if the answer to the previous question is yes, obviously |
For points 2 and 3, the changes would apply to both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review done. I think we're almost there. :)
include!(concat!( | ||
env!("CARGO_MANIFEST_DIR"), | ||
"/", | ||
"src/path_utils.rs" | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really weird to include something. Is there a reason to do this over use miniserve::path_utils
? You would have to make it public but that's fine.
format!("rm?path=/{}", make_get_path(unencoded_path)) | ||
} | ||
|
||
fn assert_rm_ok(base_url: Url, unencoded_paths: &[impl AsRef<Path>]) -> anyhow::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use anyhow::Result in any tests. Could you please take a look at how we do this in upload_files.rs
and follow that? Basically use fixtures::Error
with normal Result
s.
/// Files nested at different levels under the same root directory | ||
/// | ||
/// This is not a `&[&str]` because in percent-encoding, path segments and full paths | ||
/// are encoded differently. | ||
#[allow(dead_code)] | ||
pub static DEEPLY_NESTED_FILE: &str = "very/deeply/nested/test.rs"; | ||
pub static NESTED_FILES_UNDER_SINGLE_ROOT: LazyLock<Vec<&Path>> = LazyLock::new(|| { | ||
vec![ | ||
Path::new("someDir/alpha"), | ||
Path::new("someDir/some_sub_dir/bravo"), | ||
] | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't really understand. Where is this relevant and why now?
dir.to_str().unwrap() | ||
}) | ||
.collect::<Vec<_>>(); | ||
dbg!(&dir_names); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep this dbg!()
here? If so, it should at least get a better message with it.
/// The `check_paths_exist` parameter allows skipping this check before and after | ||
/// the deletion attempt in case these paths should be inaccessible via GET. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good start but please also describe the intent of the function as well.
format!("rm?path=/{}", make_get_path(unencoded_path)) | ||
} | ||
|
||
fn assert_rm_ok(base_url: Url, unencoded_paths: &[impl AsRef<Path>]) -> anyhow::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give this function a proper doc comment as it's quite complex.
fn rm_disabled_by_default(server: TestServer) -> anyhow::Result<()> { | ||
let paths = [FILES, DIRECTORIES] | ||
.concat() | ||
.into_iter() | ||
.map(Path::new) | ||
.chain(iter::once(DEEPLY_NESTED_FILE.as_ref())) | ||
.collect::<Vec<_>>(); | ||
assert_rm_err(server.url(), &paths, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, for all of these days I wonder whether it wouldn't be nicer and more obvious to use rstest more in the way that it was intended and have test-cases generated? Currently all paths are tested in the same test which is not really the intention of rstest. Maybe take a look at how we do things in upload_files.rs
and try to follow that?
Excuse the conflicts, should be fairly easy to rebase, though. |
Yeah, I think that would be safer and probably also more convenient. I can't think of many cases where I want to just click something and it'll be deleted right then and there without confirmation. I suspect users have also grown to expect confirmations for deletions.
You are correct, of course. I didn't consider that the paths can become valid during runtime. I think documenting this more clearly would make sense for sure as it had even me confused :D
I'm not really sure it makes sense. How would we even present that to the user? Currently serving a single file just gives you that file directly without any UI. I'm not sure supporting
|
Agreed, no need to do it in this one. |
@cyqsimon wanna push this over the finish line? |
Yeah but I'm on vacation at the moment and connectivity is shoddy. Thanks for the reminder though, will try to find some time for this. |
Closes #397.
Todo