diff --git a/controllers/data_controller/export_controller.go b/controllers/data_controller/export_controller.go index 7ec542a6f0931f15010e36d97d76bd543c6f18ad..22639b562c81961cbe2213fef8fbb25ef45f0c4d 100644 --- a/controllers/data_controller/export_controller.go +++ b/controllers/data_controller/export_controller.go @@ -32,6 +32,7 @@ type manifestRecord struct { Origin string `json:"origin"` MediaId string `json:"media_id"` CreatedTs int64 `json:"created_ts"` + Uploader string `json:"uploader"` } type manifest struct { @@ -267,6 +268,7 @@ func compileArchive(exportId string, entityId string, archiveDs *datastore.Datas Origin: m.Origin, MediaId: m.MediaId, CreatedTs: m.CreationTs, + Uploader: m.UserId, } indexModel.Media = append(indexModel.Media, &templating.ExportIndexMediaModel{ ExportID: exportId, @@ -280,6 +282,7 @@ func compileArchive(exportId string, entityId string, archiveDs *datastore.Datas ContentType: m.ContentType, UploadTs: m.CreationTs, UploadDateHuman: util.FromMillis(m.CreationTs).Format(time.UnixDate), + Uploader: m.UserId, }) } manifest := &manifest{ diff --git a/controllers/data_controller/import_controller.go b/controllers/data_controller/import_controller.go index c769d4893af24bf86bb0eea9eac3d224770d9998..51a4029a8ba9a902d0b30bc7d33b988927f68ce1 100644 --- a/controllers/data_controller/import_controller.go +++ b/controllers/data_controller/import_controller.go @@ -271,12 +271,18 @@ func doImport(updateChannel chan *importUpdate, taskId int, importId string, ctx break } + // Use the user ID (if any) as the uploader as a default. If this is an import + // for a server then we use the recorded one, if any is available. + uploader := userId + if userId == "" { + uploader = record.Uploader + } media := &types.Media{ Origin: record.Origin, MediaId: record.MediaId, UploadName: record.FileName, ContentType: record.ContentType, - UserId: userId, + UserId: uploader, Sha256Hash: record.Sha256, SizeBytes: record.SizeBytes, DatastoreId: ds.DatastoreId, diff --git a/templating/models.go b/templating/models.go index d047e0da869284be4dc669ebad5dc6fecb8aea39..486f2f4b7c3c3d68d76383cddf03d3c5df70c90a 100644 --- a/templating/models.go +++ b/templating/models.go @@ -26,6 +26,7 @@ type ExportIndexMediaModel struct { UploadDateHuman string Sha256Hash string ContentType string + Uploader string } type ExportIndexModel struct {