-
Notifications
You must be signed in to change notification settings - Fork 14
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
Use a tempfile for file fields #7
Comments
Thanks for your advice. If the developer ignores files that are stored in the file system after calling the impl Drop for MultipartFormData {
#[inline]
fn drop(&mut self) {
let files = &self.files;
for field in files.values() {
match field {
FileField::Single(f) => {
try_delete(&f.path);
}
FileField::Multiple(vf) => {
for f in vf {
try_delete(&f.path);
}
}
}
}
}
} Therefore, I think using The tempfile() function is using the |
Thanks for getting back to me! I didn't realize there was already some functionality for this. I noticed a couple files hanging around, and naively searched for Would it then make sense to add a lifetime to The manpage for char path[PATH_MAX];
fd = open("/path/to/dir", O_TMPFILE | O_RDWR,
S_IRUSR | S_IWUSR);
/* File I/O on 'fd'... */
linkat(fd, NULL, AT_FDCWD, "/path/for/file", AT_EMPTY_PATH);
/* If the caller doesn't have the CAP_DAC_READ_SEARCH
capability (needed to use AT_EMPTY_PATH with linkat(2)),
and there is a proc(5) filesystem mounted, then the
linkat(2) call above can be replaced with:
snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd);
linkat(AT_FDCWD, path, AT_FDCWD, "/path/for/file",
AT_SYMLINK_FOLLOW);
*/ |
Is there any benefit to add a lifetime which is not necessary? If |
I would say so. It clearly indicates to the developer that the
I think you can use Other unix implementations create the file normally, then unlink it immediately. I don't think there's a way to relink the file. |
If a file is uploaded by a user, and stored in the file system, it hangs around forever. If the program exits, crashes, or even if the developer ignores the file, it will clutter the temp directory.
I think using
tempfile()
(or if there are too many issues with unnamed files,NamedTempFile
) would deal with the issue effectively.The text was updated successfully, but these errors were encountered: