{"action":"created","issue":{"url":"https://api.github.com/repos/matthewwithanm/django-imagekit/issues/315","labels_url":"https://api.github.com/repos/matthewwithanm/django-imagekit/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/matthewwithanm/django-imagekit/issues/315/comments","events_url":"https://api.github.com/repos/matthewwithanm/django-imagekit/issues/315/events","html_url":"https://github.com/matthewwithanm/django-imagekit/issues/315","id":62684547,"number":315,"title":"\"The storage backend did not save the file\" warnings and \"IOError: [Errno 2] No such file or directory\"","user":{"login":"idealatom","id":2185523,"avatar_url":"https://avatars.githubusercontent.com/u/2185523?v=3","gravatar_id":"","url":"https://api.github.com/users/idealatom","html_url":"https://github.com/idealatom","followers_url":"https://api.github.com/users/idealatom/followers","following_url":"https://api.github.com/users/idealatom/following{/other_user}","gists_url":"https://api.github.com/users/idealatom/gists{/gist_id}","starred_url":"https://api.github.com/users/idealatom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idealatom/subscriptions","organizations_url":"https://api.github.com/users/idealatom/orgs","repos_url":"https://api.github.com/users/idealatom/repos","events_url":"https://api.github.com/users/idealatom/events{/privacy}","received_events_url":"https://api.github.com/users/idealatom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-03-18T12:42:42Z","updated_at":"2015-03-30T17:11:06Z","closed_at":null,"body":"Hello. I came across a problem with imagekit.\r\nI see a lot of warnings in Sentry from _generate method of ImageCacheFile - **\"The storage backend %s did not save the file with the requested name (\"%s\") and instead used \"%s\"\"**.\r\nAlso I have even more errors \"IOError: [Errno 2] No such file or directory:\"\r\n```\r\nIOError: [Errno 2] No such file or directory: u'/home/user/plitka/3dplitka/plitka/media/CACHE/images/images/tiles/images/europa-ceramica/dube/dec-angeles-dekor-01-20x50.a469216b4a05.jpeg'\r\n\r\nStacktrace (most recent call last):\r\n\r\n  File \"django/core/handlers/base.py\", line 109, in get_response\r\n    response = callback(request, *callback_args, **callback_kwargs)\r\n  File \"newrelic/hooks/framework_django.py\", line 485, in wrapper\r\n    return wrapped(*args, **kwargs)\r\n  File \"django/views/decorators/csrf.py\", line 77, in wrapped_view\r\n    return view_func(*args, **kwargs)\r\n  File \"plitka/catalog/views.py\", line 868, in ajax_search\r\n    style = 'style=\"margin: %dpx %dpx\"' % ((82 - image.height) / 2, (82 - image.width) / 2)\r\n  File \"django/core/files/images.py\", line 19, in _get_height\r\n    return self._get_image_dimensions()[1]\r\n  File \"django/core/files/images.py\", line 25, in _get_image_dimensions\r\n    self.open()\r\n  File \"imagekit/files.py\", line 58, in open\r\n    self._require_file()\r\n  File \"imagekit/cachefiles/__init__.py\", line 62, in _require_file\r\n    self._file = self.storage.open(self.name, 'rb')\r\n  File \"django/core/files/storage.py\", line 33, in open\r\n    return self._open(name, mode)\r\n  File \"django/core/files/storage.py\", line 155, in _open\r\n    return File(open(self.path(name), mode))\r\n```\r\nThis errors raises randomly, on different pages in small percent of requests . And if I reload same page right after error everything will be ok. There is no errors in my local devserver. Looks like some race condition situation. Here is different traceback:\r\n```\r\nIOError: [Errno 2] No such file or directory: u'/home/user/plitka/3dplitka/plitka/media/CACHE/images/santehnika/gemelli/glass-2/22684/gemelli-glass-2-glass-console-90-podvesnaya-colorglass.7017f7db9e2d.JPG'\r\n\r\nStacktrace (most recent call last):\r\n\r\n  File \"django/core/handlers/base.py\", line 134, in get_response\r\n    response = response.render()\r\n  File \"django/template/response.py\", line 104, in render\r\n    self._set_content(self.rendered_content)\r\n  File \"django/template/response.py\", line 81, in rendered_content\r\n    content = template.render(context)\r\n  File \"django/template/base.py\", line 140, in render\r\n    return self._render(context)\r\n  File \"newrelic/api/function_trace.py\", line 79, in dynamic_wrapper\r\n    return wrapped(*args, **kwargs)\r\n  File \"django/template/base.py\", line 134, in _render\r\n    return self.nodelist.render(context)\r\n  File \"django/template/base.py\", line 823, in render\r\n    bit = self.render_node(node, context)\r\n  File \"django/template/base.py\", line 837, in render_node\r\n    return node.render(context)\r\n  File \"django/template/loader_tags.py\", line 123, in render\r\n    return compiled_parent._render(context)\r\n  File \"newrelic/api/function_trace.py\", line 79, in dynamic_wrapper\r\n    return wrapped(*args, **kwargs)\r\n  File \"django/template/base.py\", line 134, in _render\r\n    return self.nodelist.render(context)\r\n  File \"django/template/base.py\", line 823, in render\r\n    bit = self.render_node(node, context)\r\n  File \"django/template/base.py\", line 837, in render_node\r\n    return node.render(context)\r\n  File \"django/template/loader_tags.py\", line 123, in render\r\n    return compiled_parent._render(context)\r\n  File \"newrelic/api/function_trace.py\", line 79, in dynamic_wrapper\r\n    return wrapped(*args, **kwargs)\r\n  File \"django/template/base.py\", line 134, in _render\r\n    return self.nodelist.render(context)\r\n  File \"django/template/base.py\", line 823, in render\r\n    bit = self.render_node(node, context)\r\n  File \"django/template/base.py\", line 837, in render_node\r\n    return node.render(context)\r\n  File \"newrelic/hooks/framework_django.py\", line 685, in wrapper\r\n    return wrapped(*args, **kwargs)\r\n  File \"django/template/loader_tags.py\", line 62, in render\r\n    result = block.nodelist.render(context)\r\n  File \"django/template/base.py\", line 823, in render\r\n    bit = self.render_node(node, context)\r\n  File \"django/template/base.py\", line 837, in render_node\r\n    return node.render(context)\r\n  File \"django/template/base.py\", line 874, in render\r\n    output = self.filter_expression.resolve(context)\r\n  File \"django/template/base.py\", line 571, in resolve\r\n    obj = self.var.resolve(context)\r\n  File \"django/template/base.py\", line 721, in resolve\r\n    value = self._resolve_lookup(context)\r\n  File \"django/template/base.py\", line 754, in _resolve_lookup\r\n    current = getattr(current, bit)\r\n  File \"django/core/files/images.py\", line 15, in _get_width\r\n    return self._get_image_dimensions()[0]\r\n  File \"django/core/files/images.py\", line 25, in _get_image_dimensions\r\n    self.open()\r\n  File \"imagekit/files.py\", line 58, in open\r\n    self._require_file()\r\n  File \"imagekit/cachefiles/__init__.py\", line 62, in _require_file\r\n    self._file = self.storage.open(self.name, 'rb')\r\n  File \"django/core/files/storage.py\", line 33, in open\r\n    return self._open(name, mode)\r\n  File \"django/core/files/storage.py\", line 155, in _open\r\n    return File(open(self.path(name), mode))\r\n```\r\n\r\nI'm using Imagekit 3.2.4 with Django 1.4.14. This is my imagekit settings:\r\nIMAGEKIT_SPEC_CACHEFILE_NAMER = 'imagekit.cachefiles.namers.source_name_dot_hash'\r\n\r\nThis is my imagegenerators:\r\n```python\r\nfrom imagekit import ImageSpec, register\r\nfrom imagekit.processors import ResizeToFit, ResizeToFill\r\n\r\n\r\nclass ProductBigThumbnail(ImageSpec):\r\n    processors = [ResizeToFit(290, 290, mat_color='white')]\r\n    format = 'JPEG'\r\n    options = {\r\n        'quality': 95,\r\n        'optimize': True,\r\n        'progressive': True,\r\n    }\r\n\r\n\r\nclass ProductThumbnail(ImageSpec):\r\n    processors = [ResizeToFit(65, 65, mat_color='white')]\r\n    format = 'JPEG'\r\n    options = {\r\n        'quality': 95,\r\n        'optimize': True,\r\n        'progressive': True,\r\n    }\r\n\r\n\r\nclass ProductCardThumbnail(ImageSpec):\r\n    processors = [ResizeToFit(180, 180, mat_color='white')]\r\n    format = 'JPEG'\r\n    options = {\r\n        'quality': 95,\r\n        'optimize': True,\r\n        'progressive': True,\r\n    }\r\n\r\n\r\nclass ProductCartThumbnail(ImageSpec):\r\n    processors = [ResizeToFit(100, 100, mat_color='white')]\r\n    format = 'JPEG'\r\n    options = {\r\n        'quality': 95,\r\n        'optimize': True,\r\n        'progressive': True,\r\n    }\r\n\r\n\r\nregister.generator('plumbing:product_big_thumb', ProductBigThumbnail)\r\nregister.generator('plumbing:product_thumb', ProductThumbnail)\r\nregister.generator('plumbing:product_card_thumb', ProductCardThumbnail)\r\nregister.generator('plumbing:product_cart_thumb', ProductCartThumbnail)\r\n```\r\n\r\nHere's how I use its in templates:\r\n```html\r\n{% generateimage 'plumbing:product_thumb' source=component.to_product.get_image as thumb %}\r\n<img src=\"{{ thumb.url }}\" width=\"{{ thumb.width }}\" height=\"{{ thumb.height}}\">\r\n```\r\n\r\n\r\nAlso I have this function for generating thumbnails in views:\r\n```python\r\nfrom imagekit.cachefiles import ImageCacheFile\r\nfrom imagekit.registry import generator_registry\r\nfrom imagekit.templatetags.imagekit import DEFAULT_THUMBNAIL_GENERATOR\r\n\r\n\r\ndef make_thumbnail(source, width, height, generator_id=None):\r\n    if generator_id is None:\r\n        generator_id = DEFAULT_THUMBNAIL_GENERATOR\r\n    kwargs = {\r\n        'source': source,\r\n        'width': width,\r\n        'height': height,\r\n    }\r\n    generator = generator_registry.get(generator_id, **kwargs)\r\n    return ImageCacheFile(generator)\r\n```\r\n\r\nI use this function like here, where get_image function returns value of ImageField:\r\n```python\r\nimage = make_thumbnail(it.get_image(), 82, 82)\r\nstyle = 'style=\"margin: %dpx %dpx\"' % ((82 - image.height) / 2, (82 - image.width) / 2)\r\n```\r\n\r\n\r\nCould you tell me why warnings are happens? What is the possible cause of this warnings and errors?"},"comment":{"url":"https://api.github.com/repos/matthewwithanm/django-imagekit/issues/comments/87754001","html_url":"https://github.com/matthewwithanm/django-imagekit/issues/315#issuecomment-87754001","issue_url":"https://api.github.com/repos/matthewwithanm/django-imagekit/issues/315","id":87754001,"user":{"login":"idealatom","id":2185523,"avatar_url":"https://avatars.githubusercontent.com/u/2185523?v=3","gravatar_id":"","url":"https://api.github.com/users/idealatom","html_url":"https://github.com/idealatom","followers_url":"https://api.github.com/users/idealatom/followers","following_url":"https://api.github.com/users/idealatom/following{/other_user}","gists_url":"https://api.github.com/users/idealatom/gists{/gist_id}","starred_url":"https://api.github.com/users/idealatom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idealatom/subscriptions","organizations_url":"https://api.github.com/users/idealatom/orgs","repos_url":"https://api.github.com/users/idealatom/repos","events_url":"https://api.github.com/users/idealatom/events{/privacy}","received_events_url":"https://api.github.com/users/idealatom/received_events","type":"User","site_admin":false},"created_at":"2015-03-30T17:11:06Z","updated_at":"2015-03-30T17:11:06Z","body":"\r\n@nex2hex, I add call of os.path.exist() in make_thumbnail function. Lets see if it works.\r\n"}}