Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
default to not clone static resources on local dev (#7827)
Browse files Browse the repository at this point in the history
  • Loading branch information
HexaField authored Mar 29, 2023
1 parent 59a52de commit 7b9d62d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env.local.default
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ LOCAL_STORAGE_PROVIDER_PORT=8642
GOOGLE_ANALYTICS_TRACKING_ID=
HUB_ENDPOINT=https://etherealengine.io
INSTANCESERVER_UNREACHABLE_TIMEOUT_SECONDS=10

CLONE_STATIC_RESOURCES=false


MATCHMAKER_EMULATION_MODE=true
Expand Down
2 changes: 2 additions & 0 deletions packages/server-core/src/appconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ const server = {
localStorageProviderPort: process.env.LOCAL_STORAGE_PROVIDER_PORT!,
corsServerPort: process.env.CORS_SERVER_PORT!,
storageProvider: process.env.STORAGE_PROVIDER!,
cloneProjectStaticResources:
typeof process.env.CLONE_STATIC_RESOURCES === 'undefined' ? true : process.env.CLONE_STATIC_RESOURCES === 'true',
gaTrackingId: process.env.GOOGLE_ANALYTICS_TRACKING_ID!,
hub: {
endpoint: process.env.HUB_ENDPOINT!
Expand Down
3 changes: 2 additions & 1 deletion packages/server-core/src/media/audio/audio-upload.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Readable } from 'stream'
import { AudioInterface } from '@etherealengine/common/src/dbmodels/Audio'

import { Application } from '../../../declarations'
import config from '../../appconfig'
import logger from '../../ServerLogger'
import { uploadMediaStaticResource } from '../static-resource/static-resource-helper'

Expand Down Expand Up @@ -96,7 +97,7 @@ export const audioUpload = async (app: Application, data) => {
})
}

if (existingResource && existingAudio) return existingAudio
if (!config.server.cloneProjectStaticResources || (existingResource && existingAudio)) return existingAudio
else {
let file, body
if (data.url) {
Expand Down
4 changes: 3 additions & 1 deletion packages/server-core/src/media/image/image-upload.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Op } from 'sequelize'
import { Readable } from 'stream'

import { Application } from '../../../declarations'
import config from '../../appconfig'
import logger from '../../ServerLogger'
import { uploadMediaStaticResource } from '../static-resource/static-resource-helper'

Expand Down Expand Up @@ -77,7 +78,8 @@ export const imageUpload = async (app: Application, data) => {
]
}
})
if (existingResource && existingImage) return app.service('image').get(existingImage.id)
if (!config.server.cloneProjectStaticResources || (existingResource && existingImage))
return app.service('image').get(existingImage.id)
else {
let file, body
if (data.url) {
Expand Down
4 changes: 3 additions & 1 deletion packages/server-core/src/media/model/model-upload.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Readable } from 'stream'
import { CommonKnownContentTypes } from '@etherealengine/common/src/utils/CommonKnownContentTypes'

import { Application } from '../../../declarations'
import config from '../../appconfig'
import logger from '../../ServerLogger'
import { addGenericAssetToS3AndStaticResources } from '../upload-asset/upload-asset.service'

Expand Down Expand Up @@ -77,7 +78,8 @@ export const modelUpload = async (app: Application, data) => {
]
}
})
if (existingResource && existingModel) return app.service('model').get(existingModel.id)
if (!config.server.cloneProjectStaticResources || (existingResource && existingModel))
return app.service('model').get(existingModel.id)
else {
let file, body
if (data.url) {
Expand Down
3 changes: 2 additions & 1 deletion packages/server-core/src/media/video/video-upload.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Op } from 'sequelize'
import { Readable } from 'stream'

import { Application } from '../../../declarations'
import config from '../../appconfig'
import logger from '../../ServerLogger'
import { uploadMediaStaticResource } from '../static-resource/static-resource-helper'

Expand Down Expand Up @@ -85,7 +86,7 @@ export const videoUpload = async (app: Application, data, parentId?: string, par
include
})
}
if (existingResource && existingVideo) return existingVideo
if (!config.server.cloneProjectStaticResources || (existingResource && existingVideo)) return existingVideo
else {
let file, body
if (data.url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fetch from 'node-fetch'
import { Op } from 'sequelize'

import { Application } from '../../../declarations'
import config from '../../appconfig'
import logger from '../../ServerLogger'
import { addGenericAssetToS3AndStaticResources } from '../upload-asset/upload-asset.service'
import { videoUpload } from '../video/video-upload.helper'
Expand Down Expand Up @@ -41,7 +42,7 @@ const handleManifest = async (app: Application, url: string, name = 'untitled',
]
})
}
if (existingResource && existingData) return existingData
if (!config.server.cloneProjectStaticResources || (existingResource && existingData)) return existingData
else {
if (!existingResource) {
let file, body
Expand Down

0 comments on commit 7b9d62d

Please sign in to comment.