mirror of
https://github.com/strapi/strapi.git
synced 2025-07-19 15:06:11 +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 transaction = this.transaction;
|
||||
const backupDirectory = this.uploadsBackupDirectoryName;
|
||||
const fileEntitiesMapper = this.#entitiesMapper['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
|
||||
if (uploadData?.type) {
|
||||
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];
|
||||
if (specificFormat) {
|
||||
specificFormat.url = uploadData.url;
|
||||
}
|
||||
await strapi.db.query('plugin::upload.file').update({
|
||||
where: { hash: uploadData.mainHash },
|
||||
where: { id: entry.id },
|
||||
data: {
|
||||
formats: entry.formats,
|
||||
provider,
|
||||
@ -373,11 +374,11 @@ class LocalStrapiDestinationProvider implements IDestinationProvider {
|
||||
return callback();
|
||||
}
|
||||
const entry: IFile = await strapi.db.query('plugin::upload.file').findOne({
|
||||
where: { hash: uploadData.hash },
|
||||
where: { id: fileEntitiesMapper[uploadData.id] },
|
||||
});
|
||||
entry.url = uploadData.url;
|
||||
await strapi.db.query('plugin::upload.file').update({
|
||||
where: { hash: uploadData.hash },
|
||||
where: { id: entry.id },
|
||||
data: {
|
||||
url: entry.url,
|
||||
provider,
|
||||
|
@ -94,10 +94,9 @@ export const createAssetsStream = (strapi: LoadedStrapi): Duplex => {
|
||||
const fileFormatFilepath = isLocalProvider
|
||||
? join(strapi.dirs.static.public, fileFormat.url)
|
||||
: fileFormat.url;
|
||||
|
||||
const fileFormatStats = await getFileStats(fileFormatFilepath, isLocalProvider);
|
||||
const fileFormatStream = getFileStream(fileFormatFilepath, isLocalProvider);
|
||||
const metadata = { ...fileFormat, type: format, mainHash: file.hash };
|
||||
const metadata = { ...fileFormat, type: format, id: file.id };
|
||||
yield {
|
||||
metadata,
|
||||
filepath: fileFormatFilepath,
|
||||
|
@ -25,7 +25,7 @@ export const createDispatcher = (
|
||||
ws: WebSocket,
|
||||
retryMessageOptions = {
|
||||
retryMessageMaxRetries: 5,
|
||||
retryMessageTimeout: 15000,
|
||||
retryMessageTimeout: 30000,
|
||||
}
|
||||
) => {
|
||||
const state: IDispatcherState = {};
|
||||
|
@ -130,6 +130,7 @@ export interface IConfiguration<T = unknown> {
|
||||
}
|
||||
|
||||
interface IFile {
|
||||
id: number;
|
||||
name: string;
|
||||
alternativeText?: string;
|
||||
caption?: string;
|
||||
@ -146,7 +147,6 @@ interface IFile {
|
||||
provider?: string;
|
||||
provider_metadata?: Record<string, unknown>;
|
||||
type?: string;
|
||||
mainHash?: string;
|
||||
}
|
||||
export interface IAsset {
|
||||
filename: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user