Ver Fonte

HUE-5173 [fb] Raise S3UploadError if user does not have permissions to upload

Jenny Kim há 9 anos atrás
pai
commit
33e491d
1 ficheiros alterados com 8 adições e 3 exclusões
  1. 8 3
      desktop/libs/aws/src/aws/s3/s3fs.py

+ 8 - 3
desktop/libs/aws/src/aws/s3/s3fs.py

@@ -53,8 +53,13 @@ def auth_error_handler(view_fn):
       return view_fn(*args, **kwargs)
     except (S3ResponseError, IOError), e:
       if 'Forbidden' in str(e) or e.status == 403:
-        path = args[1]  # We assume the source path is the first argument
-        raise S3FileSystemException(_('User is not authorized to write or modify path: %s. Check that user has write permissions.') % path)
+        path = kwargs.get('path')
+        if not path and len(args) > 1:
+          path = args[1]  # We assume that the path is the first argument
+        msg = _('User is not authorized to perform the attempted operation. Check that the user has appropriate permissions.')
+        if path:
+          msg = _('User is not authorized to write or modify path: %s. Check that the user has write permissions.') % path
+        raise S3FileSystemException(msg)
       else:
         raise S3FileSystemException(e.message or e.reason)
     except Exception, e:
@@ -462,7 +467,7 @@ class S3FileSystem(object):
         self.remove(path=tmp_path)
       else:
         self.open(path)
-    except (S3ResponseError, IOError), e:
+    except Exception, e:
       LOG.warn('S3 check_access encountered error verifying %s permission at path "%s": %s' % (permission, path, str(e)))
       return False
     return True