2
\$\begingroup\$

What I want to do is host a local test server that has the file, and connect to it from a local client which doesn't have the file. The only issue is that both the server and the client will look for the file in the same place. So if the server has it, the client will as well. This means if I try to test the download process, it won't actually happen because the client already has the file.

I know I can test this by using two separate computers, but is there any good way to set this up locally without changing the code? Can I make a file visible to one process but not another?

\$\endgroup\$
1
  • 2
    \$\begingroup\$ "both the server and the client will look for the file in the same place" - Why not start from 2 different places then? \$\endgroup\$
    – Kromster
    Jul 19 at 10:03
1
\$\begingroup\$

You can run a virtual machine for either the server or the client. That way you don't need to have two physical computers.

\$\endgroup\$
1
  • \$\begingroup\$ That's true! I'm surprised I didn't think of that one. \$\endgroup\$
    – flarn2006
    Aug 1 at 23:11
1
\$\begingroup\$

One thing you can do is make the addon path user-configurable. Besides allowing you to configure this differently on the server and the client, your end users may also find this feature useful, especially if they have multiple storage drives on their computer.

However, at least under Linux, it is possible to have a directory show up as having different contents for two different processes, by using what's called a mount namespace. By placing a process in a new mount namespace, it is possible to mount volumes which will only exist for that process and its subprocesses. If you create a new mount namespace, and mount a temporary file system on top of the addon content directory, you can then start the client in the new namespace and the server outside of it, and the client and server will see entirely different contents in that directory.

For the following instructions, replace $ADDON_DIR with the path to the addon content directory, and $USER with your local username:

  1. Start the server normally, and tell it to use an addon you have installed.

  2. Run sudo unshare -m in a terminal, and enter your password. This will bring you to a root shell in a new mount namespace.

  3. At the root prompt, run mount -t tmpfs tmpfs $ADDON_DIR. This will mount a temporary, empty filesystem over the addon content directory, but will only take effect within the new mount namespace.

  4. At the same prompt, type runuser $USER. This will switch back to your regular user in a subshell, which is still inside the new namespace.

  5. From that subshell, launch the game client and connect to the local server. Since the client is running in the new mount namespace, it will see an empty addon content directory, and proceed to download the content.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.