work on importing
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
node_modules
|
||||
client/dist
|
||||
server/build
|
||||
server/tmp
|
||||
server/games
|
||||
server/lakefile.olean
|
||||
**/lake-packages/
|
||||
**/.DS_Store
|
||||
|
||||
+21
-10
@@ -78,13 +78,23 @@ async function doImport (owner, repo, id) {
|
||||
.reduce((acc, cur) => acc.created_at < cur.created_at ? cur : acc)
|
||||
artifactId = artifact.id
|
||||
const url = artifact.archive_download_url
|
||||
if (!fs.existsSync("tmp")){
|
||||
fs.mkdirSync("tmp");
|
||||
if (!fs.existsSync("games")){
|
||||
fs.mkdirSync("games");
|
||||
}
|
||||
if (!fs.existsSync("games/tmp")){
|
||||
fs.mkdirSync("games/tmp");
|
||||
}
|
||||
if (!fs.existsSync(`games/${owner}`)){
|
||||
fs.mkdirSync(`games/${owner}`);
|
||||
}
|
||||
progress[id].output += `Download from ${url}\n`
|
||||
await download(id, url, `tmp/artifact_${artifactId}.zip`)
|
||||
// await download(id, url, `games/tmp/${owner.toLowerCase()}_${repo.toLowerCase()}_${artifactId}.zip`)
|
||||
progress[id].output += `Download finished.\n`
|
||||
await runProcess(id, "/bin/bash", [`${__dirname}/unpack.sh`, artifactId],".")
|
||||
|
||||
// BUG: it doesn't wait for this to finish
|
||||
await runProcess(id, "/bin/bash", [`${__dirname}/unpack.sh`, artifactId, owner.toLowerCase(), repo.toLowerCase()], ".")
|
||||
|
||||
|
||||
// let manifest = fs.readFileSync(`tmp/artifact_${artifactId}_inner/manifest.json`);
|
||||
// manifest = JSON.parse(manifest);
|
||||
// if (manifest.length !== 1) {
|
||||
@@ -103,14 +113,15 @@ async function doImport (owner, repo, id) {
|
||||
} catch (e) {
|
||||
progress[id].output += `Error: ${e.toString()}\n${e.stack}`
|
||||
} finally {
|
||||
if (artifactId) {
|
||||
// fs.rmSync(`tmp/artifact_${artifactId}.zip`, {force: true, recursive: true});
|
||||
// fs.rmSync(`tmp/artifact_${artifactId}`, {force: true, recursive: true});
|
||||
// fs.rmSync(`tmp/artifact_${artifactId}_inner`, {force: true, recursive: true});
|
||||
// fs.rmSync(`tmp/archive_${artifactId}.tar`, {force: true, recursive: true});
|
||||
}
|
||||
// if (artifactId) {
|
||||
// // fs.rmSync(`tmp/artifact_${artifactId}.zip`, {force: true, recursive: true});
|
||||
// // fs.rmSync(`tmp/artifact_${artifactId}`, {force: true, recursive: true});
|
||||
// // fs.rmSync(`tmp/artifact_${artifactId}_inner`, {force: true, recursive: true});
|
||||
// // fs.rmSync(`tmp/archive_${artifactId}.tar`, {force: true, recursive: true});
|
||||
// }
|
||||
progress[id].done = true
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 10000))
|
||||
}
|
||||
|
||||
export const importTrigger = (req, res) => {
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ function startServerProcess(owner, repo) {
|
||||
|
||||
let serverProcess
|
||||
if (isDevelopment) {
|
||||
let args = ["--server", path.join("../../../../", game_dir)]
|
||||
let args = ["--server", path.join('..','..','games',`${owner}`,`${repo}`)]
|
||||
serverProcess = cp.spawn("./gameserver", args,
|
||||
{ cwd: path.join(__dirname, "./build/bin/") })
|
||||
} else {
|
||||
|
||||
Regular → Executable
+11
-5
@@ -1,13 +1,19 @@
|
||||
#/bin/bash
|
||||
|
||||
ARTIFACT_ID=$1
|
||||
OWNER=$2
|
||||
REPO=$3
|
||||
|
||||
echo "Unpacking ZIP."
|
||||
unzip -o tmp/artifact_${ARTIFACT_ID}.zip -d tmp/artifact_${ARTIFACT_ID}
|
||||
echo "Unpacking TAR."
|
||||
for f in tmp/artifact_${ARTIFACT_ID}/* #Should only be one file
|
||||
# unzip -o games/tmp/${OWNER}_${REPO}_${ARTIFACT_ID}.zip -d games/tmp/${OWNER}_${REPO}_${ARTIFACT_ID}
|
||||
echo "Unpacking game."
|
||||
rm -rf games/${OWNER}/${REPO}
|
||||
mkdir games/${OWNER}/${REPO}
|
||||
|
||||
for f in games/tmp/${OWNER}_${REPO}_${ARTIFACT_ID}/* #Should only be one file
|
||||
do
|
||||
echo "Unpacking $f"
|
||||
mkdir tmp/artifact_${ARTIFACT_ID}_inner
|
||||
tar -xvf $f -C tmp/artifact_${ARTIFACT_ID}_inner
|
||||
#tar -xvzf $f -C games/${OWNER}/${REPO}
|
||||
mkdir games/${OWNER}/${REPO}
|
||||
unzip -o $f -d games/${OWNER}/${REPO}
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user