Skip to content

Possible "leftover" attachment in case of MaximumLengthIsReachedError #124

@lelit

Description

@lelit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions