Skip to content

Upload flat project archive after hybrid execution #13528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/gui/project-manager-shim-middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ export default function projectManagerShimMiddleware(
https.get(downloadUrl, (actualResponse) => {
const projectsDirectory = projectManagement.getProjectsDirectory()
const parentDirectory = path.join(projectsDirectory, `cloud-${projectId}`)
const targetDirectory = path.join(parentDirectory, 'project_root')
const projectRootDirectory = path.join(parentDirectory, 'project_root')

fs.mkdir(targetDirectory, { recursive: true })
.then(() => projectManagement.unpackBundle(actualResponse, targetDirectory))
fs.mkdir(projectRootDirectory, { recursive: true })
.then(() => projectManagement.unpackBundle(actualResponse, projectRootDirectory))
.then(() => {
response
.writeHead(HTTP_STATUS_OK, COMMON_HEADERS)
.end(JSON.stringify({ targetDirectory, parentDirectory }))
.end(JSON.stringify({ parentDirectory, projectRootDirectory }))
})
.catch((e) => {
console.error(e)
Expand All @@ -188,14 +188,15 @@ export default function projectManagerShimMiddleware(
}
case '/api/cloud/get-project-archive': {
const url = new URL(`https://example.com/${requestUrl}`)
const projectDir = url.searchParams.get('directory')
const parentDir = url.searchParams.get('directory')

if (projectDir == null) {
if (parentDir == null) {
response
.writeHead(HTTP_STATUS_BAD_REQUEST, COMMON_HEADERS)
.end('Request is missing search parameter `directory`.')
break
}
const projectDir = path.join(parentDir, 'project_root')

projectManagement
.createBundle(projectDir)
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/hooks/projectHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ function useOpenHybridProject() {
const cloudProjectDirectoryPath = asset.ensoPath.slice(0, asset.ensoPath.lastIndexOf('/'))

let project
for (const parentId of [localProject.targetId, localProject.parentId]) {
for (const parentId of [localProject.parentId, localProject.projectRootId]) {
const assets = await localBackend.listDirectory({
parentId: parentId,
filterBy: null,
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/services/RemoteBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ export default class RemoteBackend extends Backend {
async downloadProject(id: backend.ProjectId) {
/** The type of the response body of this endpoint. */
interface ResponseBody {
readonly targetDirectory: string
readonly projectRootDirectory: string
readonly parentDirectory: string
}
const details = await this.getProjectDetails(id, true)
Expand All @@ -1408,7 +1408,7 @@ export default class RemoteBackend extends Backend {
const responseBody = await response.json()

return {
targetId: backend.DirectoryId(`directory-${responseBody.targetDirectory}`),
projectRootId: backend.DirectoryId(`directory-${responseBody.projectRootDirectory}`),
parentId: backend.DirectoryId(`directory-${responseBody.parentDirectory}`),
}
}
Expand Down
13 changes: 7 additions & 6 deletions app/ide-desktop/client/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ export class Server {
https.get(downloadUrl, async (actualResponse) => {
const projectsDirectory = projectManagement.getProjectsDirectory()
const parentDirectory = path.join(projectsDirectory, `cloud-${projectId}`)
const targetDirectory = path.join(parentDirectory, 'project_root')
const projectRootDirectory = path.join(parentDirectory, 'project_root')

try {
await fs.mkdir(targetDirectory, { recursive: true })
await projectManagement.unpackBundle(actualResponse, targetDirectory)
await fs.mkdir(projectRootDirectory, { recursive: true })
await projectManagement.unpackBundle(actualResponse, projectRootDirectory)
response
.writeHead(HTTP_STATUS_OK, COOP_COEP_CORP_HEADERS)
.end(JSON.stringify({ targetDirectory, parentDirectory }))
.end(JSON.stringify({ projectRootDirectory, parentDirectory }))
} catch (e) {
logger.error(e)
await fs
Expand All @@ -272,14 +272,15 @@ export class Server {
}
case '/api/cloud/get-project-archive': {
const url = new URL(`https://example.com/${requestUrl}`)
const projectDir = url.searchParams.get('directory')
const parentDir = url.searchParams.get('directory')

if (projectDir == null) {
if (parentDir == null) {
response
.writeHead(HTTP_STATUS_BAD_REQUEST, COOP_COEP_CORP_HEADERS)
.end('Request is missing search parameter `directory`.')
break
}
const projectDir = path.join(parentDir, 'project_root')

projectManagement
.createBundle(projectDir)
Expand Down
Loading