warn about big projects
This commit is contained in:
@ -1760,6 +1760,7 @@ export const ModelingMachineProvider = ({
|
|||||||
if (isDesktop() && context?.project?.children) {
|
if (isDesktop() && context?.project?.children) {
|
||||||
basePath = context?.selectedDirectory?.path
|
basePath = context?.selectedDirectory?.path
|
||||||
const filePromises: Promise<FileMeta | null>[] = []
|
const filePromises: Promise<FileMeta | null>[] = []
|
||||||
|
let uploadSize = 0
|
||||||
const recursivelyPushFilePromises = (files: FileEntry[]) => {
|
const recursivelyPushFilePromises = (files: FileEntry[]) => {
|
||||||
// mutates filePromises declared above, so this function definition should stay here
|
// mutates filePromises declared above, so this function definition should stay here
|
||||||
// if pulled out, it would need to be refactored.
|
// if pulled out, it would need to be refactored.
|
||||||
@ -1774,6 +1775,7 @@ export const ModelingMachineProvider = ({
|
|||||||
const filePromise = window.electron
|
const filePromise = window.electron
|
||||||
.readFile(absPath)
|
.readFile(absPath)
|
||||||
.then((file): FileMeta => {
|
.then((file): FileMeta => {
|
||||||
|
uploadSize += file.byteLength
|
||||||
const decoder = new TextDecoder('utf-8')
|
const decoder = new TextDecoder('utf-8')
|
||||||
const fileType = window.electron.path.extname(absPath)
|
const fileType = window.electron.path.extname(absPath)
|
||||||
if (fileType === '.kcl') {
|
if (fileType === '.kcl') {
|
||||||
@ -1786,12 +1788,13 @@ export const ModelingMachineProvider = ({
|
|||||||
execStateNameToIndexMap[absPath],
|
execStateNameToIndexMap[absPath],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const blob = new Blob([file], {
|
||||||
|
type: 'application/octet-stream',
|
||||||
|
})
|
||||||
return {
|
return {
|
||||||
type: 'other',
|
type: 'other',
|
||||||
relPath,
|
relPath,
|
||||||
data: new Blob([file], {
|
data: blob,
|
||||||
type: 'application/octet-stream',
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@ -1806,6 +1809,12 @@ export const ModelingMachineProvider = ({
|
|||||||
projectFiles = (await Promise.all(filePromises)).filter(
|
projectFiles = (await Promise.all(filePromises)).filter(
|
||||||
isNonNullable
|
isNonNullable
|
||||||
)
|
)
|
||||||
|
const MB20 = 2 ** 20 * 20
|
||||||
|
if (uploadSize > MB20) {
|
||||||
|
toast.error(
|
||||||
|
"You're project exceeds 20Mb, this will slow down Text-to-CAD\nPlease remove any unnecessary files"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return await promptToEditFlow({
|
return await promptToEditFlow({
|
||||||
projectFiles,
|
projectFiles,
|
||||||
|
|||||||
@ -196,6 +196,8 @@ const IMPORT_FILE_EXTENSIONS = [
|
|||||||
'glb',
|
'glb',
|
||||||
'fbxb',
|
'fbxb',
|
||||||
'kcl',
|
'kcl',
|
||||||
|
'step',
|
||||||
|
'stl',
|
||||||
]
|
]
|
||||||
|
|
||||||
const isRelevantFile = (filename: string): boolean =>
|
const isRelevantFile = (filename: string): boolean =>
|
||||||
|
|||||||
@ -359,7 +359,6 @@ export async function doPromptEdit({
|
|||||||
console.error('textToCadComplete', e)
|
console.error('textToCadComplete', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('textToCadComplete', textToCadComplete)
|
|
||||||
return textToCadComplete
|
return textToCadComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +445,6 @@ export async function promptToEditFlow({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('outputs', outputs)
|
|
||||||
if (isDesktop()) {
|
if (isDesktop()) {
|
||||||
// write all of the outputs to disk
|
// write all of the outputs to disk
|
||||||
for (const [relativePath, fileContents] of Object.entries(outputs)) {
|
for (const [relativePath, fileContents] of Object.entries(outputs)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user