Fix handling of upload IDs on backups
This commit is contained in:
parent
8e06628409
commit
952715facc
3 changed files with 10 additions and 6 deletions
|
@ -10,6 +10,7 @@ use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
|||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Extensions\Backups\BackupManager;
|
||||
use Pterodactyl\Repositories\Eloquent\BackupRepository;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class BackupRemoteUploadController extends Controller
|
||||
|
@ -64,7 +65,7 @@ class BackupRemoteUploadController extends Controller
|
|||
// Prevent backups that have already been completed from trying to
|
||||
// be uploaded again.
|
||||
if (! is_null($backup->completed_at)) {
|
||||
return new JsonResponse([], JsonResponse::HTTP_CONFLICT);
|
||||
throw new ConflictHttpException('This backup is already in a completed state.');
|
||||
}
|
||||
|
||||
// Ensure we are using the S3 adapter.
|
||||
|
@ -103,9 +104,7 @@ class BackupRemoteUploadController extends Controller
|
|||
}
|
||||
|
||||
// Set the upload_id on the backup in the database.
|
||||
$backup->forceFill([
|
||||
'upload_id' => $params['UploadId'],
|
||||
])->saveOrFail();
|
||||
$backup->update(['upload_id' => $params['UploadId']]);
|
||||
|
||||
return new JsonResponse([
|
||||
'parts' => $parts,
|
||||
|
|
|
@ -68,6 +68,11 @@ class Backup extends Model
|
|||
'upload_id' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -80,7 +85,7 @@ class Backup extends Model
|
|||
'disk' => 'required|string',
|
||||
'checksum' => 'nullable|string',
|
||||
'bytes' => 'numeric',
|
||||
'upload_id' => 'nullable|uuid',
|
||||
'upload_id' => 'nullable|string',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@ class AddUploadIdColumnToBackupsTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('backups', function (Blueprint $table) {
|
||||
$table->char('upload_id', 36)->nullable()->after('bytes');
|
||||
$table->text('upload_id')->nullable()->after('uuid');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue