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

Possible "leftover" attachment in case of MaximumLengthIsReachedError #124

Open
lelit opened this issue Nov 16, 2019 · 0 comments
Open

Possible "leftover" attachment in case of MaximumLengthIsReachedError #124

lelit opened this issue Nov 16, 2019 · 0 comments

Comments

@lelit
Copy link
Contributor

lelit commented Nov 16, 2019

In the following scenario

class Icon(SA_Image):
    __auto_coercion__ = True
    __max_length__ = 1*MB
    __min_length__ = 1*KB
    __pre_processors__ = (
        ImageAnalyzer(),
        ImageValidator(
            minimum=(16, 16),
            maximum=(600, 600),
            min_aspect_ratio=0.9,
            max_aspect_ratio=1.7777,  # 16/9
            content_types=('image/png', 'image/jpeg', 'image/gif', 'image/webp')),
        ImageProcessor(fmt='png'),
    )
    suffix = ''

when I .attach() an image bigger than 1MB, the code path reaches the store's put method, that in turn calls copy_stream(), which may raise a MaximumLengthIsReachedError exception.

At that point, the error bubbles up and terminate the request, but the incomplete target file is left in the store. I think that the put() method should intercept the error and remove the incomplete file from the store.

I tried to distill a minimal test case, but failed, sorry.

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

No branches or pull requests

1 participant