mirror of
https://github.com/strapi/strapi.git
synced 2025-07-21 07:57:45 +00:00
fix: use id instead of hash
This commit is contained in:
parent
07894142a4
commit
85e5d16fda
@ -291,6 +291,7 @@ class LocalStrapiDestinationProvider implements IDestinationProvider {
|
|||||||
const strapi = this.strapi;
|
const strapi = this.strapi;
|
||||||
const transaction = this.transaction;
|
const transaction = this.transaction;
|
||||||
const backupDirectory = this.uploadsBackupDirectoryName;
|
const backupDirectory = this.uploadsBackupDirectoryName;
|
||||||
|
const fileEntitiesMapper = this.#entitiesMapper['plugin::upload.file'];
|
||||||
|
|
||||||
const restoreMediaEntitiesContent = this.#isContentTypeIncluded('plugin::upload.file');
|
const restoreMediaEntitiesContent = this.#isContentTypeIncluded('plugin::upload.file');
|
||||||
|
|
||||||
@ -357,14 +358,14 @@ class LocalStrapiDestinationProvider implements IDestinationProvider {
|
|||||||
// Files formats are stored within the parent file entity
|
// Files formats are stored within the parent file entity
|
||||||
if (uploadData?.type) {
|
if (uploadData?.type) {
|
||||||
const entry: IFile = await strapi.db.query('plugin::upload.file').findOne({
|
const entry: IFile = await strapi.db.query('plugin::upload.file').findOne({
|
||||||
where: { hash: uploadData.mainHash },
|
where: { id: fileEntitiesMapper[uploadData.id] },
|
||||||
});
|
});
|
||||||
const specificFormat = entry?.formats?.[uploadData.type];
|
const specificFormat = entry?.formats?.[uploadData.type];
|
||||||
if (specificFormat) {
|
if (specificFormat) {
|
||||||
specificFormat.url = uploadData.url;
|
specificFormat.url = uploadData.url;
|
||||||
}
|
}
|
||||||
await strapi.db.query('plugin::upload.file').update({
|
await strapi.db.query('plugin::upload.file').update({
|
||||||
where: { hash: uploadData.mainHash },
|
where: { id: entry.id },
|
||||||
data: {
|
data: {
|
||||||
formats: entry.formats,
|
formats: entry.formats,
|
||||||
provider,
|
provider,
|
||||||
@ -373,11 +374,11 @@ class LocalStrapiDestinationProvider implements IDestinationProvider {
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
const entry: IFile = await strapi.db.query('plugin::upload.file').findOne({
|
const entry: IFile = await strapi.db.query('plugin::upload.file').findOne({
|
||||||
where: { hash: uploadData.hash },
|
where: { id: fileEntitiesMapper[uploadData.id] },
|
||||||
});
|
});
|
||||||
entry.url = uploadData.url;
|
entry.url = uploadData.url;
|
||||||
await strapi.db.query('plugin::upload.file').update({
|
await strapi.db.query('plugin::upload.file').update({
|
||||||
where: { hash: uploadData.hash },
|
where: { id: entry.id },
|
||||||
data: {
|
data: {
|
||||||
url: entry.url,
|
url: entry.url,
|
||||||
provider,
|
provider,
|
||||||
|
@ -94,10 +94,9 @@ export const createAssetsStream = (strapi: LoadedStrapi): Duplex => {
|
|||||||
const fileFormatFilepath = isLocalProvider
|
const fileFormatFilepath = isLocalProvider
|
||||||
? join(strapi.dirs.static.public, fileFormat.url)
|
? join(strapi.dirs.static.public, fileFormat.url)
|
||||||
: fileFormat.url;
|
: fileFormat.url;
|
||||||
|
|
||||||
const fileFormatStats = await getFileStats(fileFormatFilepath, isLocalProvider);
|
const fileFormatStats = await getFileStats(fileFormatFilepath, isLocalProvider);
|
||||||
const fileFormatStream = getFileStream(fileFormatFilepath, isLocalProvider);
|
const fileFormatStream = getFileStream(fileFormatFilepath, isLocalProvider);
|
||||||
const metadata = { ...fileFormat, type: format, mainHash: file.hash };
|
const metadata = { ...fileFormat, type: format, id: file.id };
|
||||||
yield {
|
yield {
|
||||||
metadata,
|
metadata,
|
||||||
filepath: fileFormatFilepath,
|
filepath: fileFormatFilepath,
|
||||||
|
@ -25,7 +25,7 @@ export const createDispatcher = (
|
|||||||
ws: WebSocket,
|
ws: WebSocket,
|
||||||
retryMessageOptions = {
|
retryMessageOptions = {
|
||||||
retryMessageMaxRetries: 5,
|
retryMessageMaxRetries: 5,
|
||||||
retryMessageTimeout: 15000,
|
retryMessageTimeout: 30000,
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
const state: IDispatcherState = {};
|
const state: IDispatcherState = {};
|
||||||
|
@ -130,6 +130,7 @@ export interface IConfiguration<T = unknown> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IFile {
|
interface IFile {
|
||||||
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
alternativeText?: string;
|
alternativeText?: string;
|
||||||
caption?: string;
|
caption?: string;
|
||||||
@ -146,7 +147,6 @@ interface IFile {
|
|||||||
provider?: string;
|
provider?: string;
|
||||||
provider_metadata?: Record<string, unknown>;
|
provider_metadata?: Record<string, unknown>;
|
||||||
type?: string;
|
type?: string;
|
||||||
mainHash?: string;
|
|
||||||
}
|
}
|
||||||
export interface IAsset {
|
export interface IAsset {
|
||||||
filename: string;
|
filename: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user