use space type from request

This commit is contained in:
Michael Barz
2021-10-06 14:44:18 +02:00
parent 21acef46d7
commit 93a76a06e7
4 changed files with 17 additions and 4 deletions
+13 -1
View File
@@ -170,6 +170,18 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, fmt.Errorf("invalid name").Error())
return
}
var driveType string
if drive.DriveType != nil {
driveType = *drive.DriveType
}
switch driveType {
case "":
driveType = "project"
case "share":
errorcode.GeneralException.Render(w, r, http.StatusBadRequest, fmt.Errorf("drives of type share cannot be created via this api").Error())
}
var quota uint64
if drive.Quota != nil && drive.Quota.Total != nil {
quota = uint64(*drive.Quota.Total)
@@ -179,7 +191,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
csr := provider.CreateStorageSpaceRequest{
Owner: us,
Type: "share",
Type: driveType,
Name: spaceName,
Quota: &provider.Quota{
QuotaMaxBytes: quota,