mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-11-10 15:16:20 -06:00
The upload was spooled to the receiving instance's temp dir and only its name travelled with the event. That holds while events stay in-process, but it ties the job to the instance that accepted the upload. Store it through the files package on the configured backend and record its id on the migration status, so the event carries only the status id and any instance can run the import. The job copies it to a local temp file first: the zip importer needs random access, which an S3 object body cannot give. The upload is removed once the import is over. An hourly cron deletes leftovers from events lost on restart or instances that died mid-import.
50 lines
1.9 KiB
Go
50 lines
1.9 KiB
Go
// Vikunja is a to-do list application to facilitate your life.
|
|
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
package handler
|
|
|
|
import (
|
|
"code.vikunja.io/api/pkg/user"
|
|
)
|
|
|
|
// MigrationRequestedEvent represents a MigrationRequestedEvent event
|
|
type MigrationRequestedEvent struct {
|
|
Migrator interface{} `json:"migrator"`
|
|
User *user.User `json:"user"`
|
|
MigratorKind string `json:"migrator_kind"`
|
|
// MigrationStatusID lets the listener reuse the claim after the event round trip.
|
|
MigrationStatusID int64 `json:"migration_status_id"`
|
|
}
|
|
|
|
// Name defines the name for MigrationRequestedEvent
|
|
func (t *MigrationRequestedEvent) Name() string {
|
|
return "migration.requested"
|
|
}
|
|
|
|
// FileMigrationRequestedEvent queues an uploaded import. The upload itself is found through the
|
|
// migration status, so the event stays small and any instance can run it.
|
|
type FileMigrationRequestedEvent struct {
|
|
User *user.User `json:"user"`
|
|
MigratorKind string `json:"migrator_kind"`
|
|
MigrationStatusID int64 `json:"migration_status_id"`
|
|
Options []byte `json:"options,omitempty"`
|
|
}
|
|
|
|
// Name defines the name for FileMigrationRequestedEvent
|
|
func (t *FileMigrationRequestedEvent) Name() string {
|
|
return "migration.file.requested"
|
|
}
|