Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Upload of txt files #9

Open
Root-Core opened this issue Jan 13, 2022 · 1 comment
Open

Upload of txt files #9

Root-Core opened this issue Jan 13, 2022 · 1 comment

Comments

@Root-Core
Copy link

Hello,

i've just started using the extension and it's working so far for scripts.
The upload of *.txt files is broken though.

This is in fact a bit confusing, as the README.md does not mention txt files - but it's in the code.

I get the toast (as activated in settings), that the file was uploaded - but it does not appear in Bitburner.
There is no error message in Bitburners debugger.

In vscode the plugin reports some errors that seem to be unrelated:

Cannot read property 'dispose' of undefined
Cannot read property 'dispose' of undefined
Cannot read property 'dispose' of undefined
Cannot read property 'dispose' of undefined

Game version (Steam): Bitburner v1.3.0 (5ebb96a0)
vscode: 1.63.2
Plugin: 1.3.3

Regards!

@BoolPurist
Copy link

BoolPurist commented Apr 3, 2022

I can reproduce this bug myself. After a bit digging into the problem, I found the following thing out.

In my opinion the bug lies in the Bitburner project, the API-Server more precisely. I don't think the vs code extension can fix it.

In short: The game refuses to accept txt files because it is not a valid script. The game only accepts script files with extensions ( .js, .script, .ns )

When the VS Code Extention pushes a file to the game then it sends a post request to the API-Server. For Post request a function, called writeToScriptFile, is called. It is for saving a script to the game. Of course this function checks if the file is a valid script by looking at the extension. The extension txt is not valid for a script file.

The API for vs code is registered in the the file "api-server".

Here we can see that it calls the following line

result = await window.webContents.executeJavaScript(`document.saveFile("${data.filename}", "${data.code}")`);"

The document object gets the function in the file Electron.tsx.

Here we can see that the appended function calls "writeToScriptFile".

This function uses isScriptFilename to validate the pushed file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants