shotvibe / shotvibe-web

ShotVibe REST API webservice
1 stars 0 forks source link

image_uploads.process_uploaded_image fails on existing symlink #15

Open benny-shotvibe opened 11 years ago

benny-shotvibe commented 11 years ago

Check out the following stacktrace. This can happen if there are symlinks left from a previous attempt that didn't finish, or possibly from simultaneous parallel calls that step on each other.

Need to catch the error, and remove the old file, and then try again (probably even in a loop, to deal with really rare race conditions of parallel calls interfering with each other)

Internal Server Error: /albums/81/
Traceback (most recent call last):
  File "/srv/shotvibe_web/1371649006/.venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/srv/shotvibe_web/1371649006/.venv/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/srv/shotvibe_web/1371649006/.venv/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 77, in wrapped_view
    return view_func(*args, **kwargs)
  File "./photos_api/check_modified.py", line 136, in dispatch
    response = self.handle_exception(exc)
  File "./photos_api/check_modified.py", line 129, in dispatch
    response = handler(request, *args, **kwargs)
  File "./photos_api/views.py", line 96, in post
    self.album.add_photos(request.user, serializer.object.add_photos)
  File "./photos/models.py", line 78, in add_photos
    Photo.objects.upload_to_album(photo_id, self, now)
  File "./photos/models.py", line 130, in upload_to_album
    width, height = image_uploads.process_uploaded_image(pending_photo.bucket, photo_id)
  File "./photos/image_uploads.py", line 222, in process_uploaded_image
    os.symlink(saved_image, os.path.join(bucket_directory, filename))
OSError: [Errno 17] File exists