Skip to content
代码片段 群组 项目
提交 c3b6d6c8 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

Remove the mechanism for zap.url file and clean up some naming.

上级 ab9abf5d
No related branches found
No related tags found
无相关合并请求
......@@ -44,7 +44,7 @@ function projectPath(db, sessionId) {
return querySession.getSessionKeyValue(
db,
sessionId,
dbEnum.sessionKey.studioProjectPath
dbEnum.sessionKey.ideProjectPath
)
}
......@@ -56,7 +56,7 @@ function projectPath(db, sessionId) {
*/
function integrationEnabled(db, sessionId) {
return querySession
.getSessionKeyValue(db, sessionId, dbEnum.sessionKey.studioProjectPath)
.getSessionKeyValue(db, sessionId, dbEnum.sessionKey.ideProjectPath)
.then((path) => typeof path !== 'undefined')
}
......
......@@ -39,7 +39,7 @@ const studio = require('../ide-integration/studio-rest-api.js')
*/
function httpPostFileOpen(db) {
return (req, res) => {
let { zapFilePath, studioFilePath } = req.body
let { zapFilePath, ideProjectPath } = req.body
let name = ''
if (zapFilePath) {
......@@ -64,28 +64,28 @@ function httpPostFileOpen(db) {
return req.zapSessionId
})
.then((sessionId) => {
if (studioFilePath != null && studioFilePath.length > 0) {
if (ideProjectPath) {
env.logDebug(
`Studio: setting project path(${name}) to ${studioFilePath}`
`IDE: setting project path(${name}) to ${ideProjectPath}`
)
// store studio project path
querySession.updateSessionKeyValue(
db,
sessionId,
dbEnum.sessionKey.studioProjectPath,
studioFilePath
dbEnum.sessionKey.ideProjectPath,
ideProjectPath
)
}
})
.catch((err) => {
.catch(function (err) {
err.project = zapFilePath
studio.sendSessionCreationErrorStatus(db, err)
env.logError(JSON.stringify(err))
res.status(http.StatusCodes.BAD_REQUEST).send(err)
})
} else {
let msg = `Opening/Loading project: Missing zap file path or Studio project file path.`
let msg = `Opening/Loading project: Missing zap file path.`
env.logWarning(msg)
res.status(http.StatusCodes.BAD_REQUEST).send({ error: msg })
}
......
......@@ -150,7 +150,6 @@ async function initHttpServer(
app.use(express.static(env.httpStaticContent))
httpServer = app.listen(port, () => {
env.logHttpServerUrl(httpServerPort(), studioPort)
resolve(app)
})
......@@ -158,7 +157,6 @@ async function initHttpServer(
env.logWarning(`HTTP server exception.`, err)
if (err.errno === 'EADDRINUSE') {
httpServer = app.listen(0, () => {
env.logHttpServerUrl(httpServerPort(), studioPort)
resolve(app)
})
} else {
......
......@@ -226,24 +226,6 @@ function baseUrl() {
return zapBaseUrl
}
function logHttpServerUrl(port, studioPort) {
logInfo('HTTP server created: ' + baseUrl() + port)
if (studioPort) {
logInfo('Studio integration server: ' + baseUrl() + studioPort)
}
fs.writeFileSync(urlLogFile(), baseUrl() + port, function (err) {
if (err) {
logError('Unable to log HTTP Server URL to ' + urlLogFile())
}
})
}
function urlLogFile(id) {
return path.join(appDirectory(), zapUrlLog)
}
/**
* Base level common logger.
*
......@@ -403,8 +385,6 @@ exports.logIpc = logIpc
exports.logDebug = logDebug
exports.zapVersion = zapVersion
exports.zapVersionAsString = zapVersionAsString
exports.logHttpServerUrl = logHttpServerUrl
exports.urlLogFile = urlLogFile
exports.baseUrl = baseUrl
exports.versionsCheck = versionsCheck
exports.setAppDirectory = setAppDirectory
......
......@@ -69,7 +69,7 @@ exports.zclType = {
exports.sessionKey = {
filePath: 'filePath',
studioProjectPath: 'studioProjectPath',
ideProjectPath: 'ideProjectPath',
}
exports.pathRelativity = {
......
......@@ -85,12 +85,12 @@ function renderer_api_info() {
}
}
function fnOpen(zapFilePath, studioFilePath) {
function fnOpen(zapFilePath, ideProjectPath) {
// Make a request for a user with a given ID
window
.axios_server_post(`${restApi.ide.open}`, {
zapFilePath,
studioFilePath,
zapFilePath: zapFilePath,
ideProjectPath: ideProjectPath,
})
.then((res) => window.location.reload())
.catch((err) => console.log(err))
......
......@@ -67,15 +67,6 @@ describe('Session specific tests', () => {
test('http server initialization', () => httpServer.initHttpServer(db, port))
test('verify server port log (~/.zap/zap.url)', () => {
expect(fs.existsSync(env.urlLogFile())).toBeTruthy()
content = fs.readFileSync(env.urlLogFile(), 'utf8')
expect(
content.trim() === env.baseUrl() + httpServer.httpServerPort()
).toBeTruthy()
})
test('get index.html', () =>
axiosInstance.get('/index.html').then((response) => {
sessionCookie = response.headers['set-cookie'][0]
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册