(ctx context.Context, config common.Config, s AvailableDriveScript)
| 141 | } |
| 142 | |
| 143 | func InstallDriveScript(ctx context.Context, config common.Config, s AvailableDriveScript) error { |
| 144 | if s.Name == "" || s.DriveURL == "" { |
| 145 | return err.NewBadRequestError("invalid installation request") |
| 146 | } |
| 147 | |
| 148 | drivesDir, e := config.GetDir(config.DrivesDir, true) |
| 149 | if e != nil { |
| 150 | return e |
| 151 | } |
| 152 | e = downloadFile(ctx, s.DriveURL, filepath.Join(drivesDir, s.Name+".js")) |
| 153 | if e != nil { |
| 154 | return e |
| 155 | } |
| 156 | if s.DriveUploaderURL != "" { |
| 157 | driveUploadersDir, e := config.GetDir(config.DriveUploadersDir, true) |
| 158 | if e != nil { |
| 159 | return e |
| 160 | } |
| 161 | e = downloadFile(ctx, s.DriveUploaderURL, filepath.Join(driveUploadersDir, s.Name+".js")) |
| 162 | if e != nil { |
| 163 | return e |
| 164 | } |
| 165 | } |
| 166 | return nil |
| 167 | } |
| 168 | |
| 169 | func UninstallDriveScript(config common.Config, name string) error { |
| 170 | if name == "" { |
no test coverage detected