SpatiumPortae / portal

Portal is a quick and easy command-line file transfer utility from any computer to another 🌌 ✨
https://portal.spatiumportae.com
MIT License
1.39k stars 35 forks source link

[feature request] Configurable /tmp directory #127

Closed johnhamelink closed 10 months ago

johnhamelink commented 12 months ago

Is your feature request related to a problem? Please describe. When trying to share 400GB of content that was stored on an external drive, the transfer failed because portal was copying the file to /tmp before sending. The /tmp directory only has access to around 50GB of space on this machine.

Describe the solution you'd like If I could change the directory to one relative to the content being sent, or otherwise configure the working directory for portal, then I could transfer these larger files on this device.

Describe alternatives you've considered I looked through --help, README, and checked for any relevant issues or PRs.

DullUnicorn commented 11 months ago

At least on Linux, you can set the TMPDIR environment variable to any directory:

TMPDIR="$HOME/.cache" portal send <files...>

You can do this on the receiving end as well:

TMPDIR="$HOME/.cache" portal receive <code>

Once that's finished, remove the temporary files in both machines manually:

rm ~/.cache/portal-*-temp*
ZinoKader commented 11 months ago

Thank you @DullUnicorn! We use the TempDir function from the os package (https://pkg.go.dev/os#TempDir).

Both on Unix systems and on Windows, this directory is configurable, so you can set/re-set it before and after transfer just as described above.

Excerpt from os.TempDir docs:

  • On Unix systems, it returns $TMPDIR if non-empty, else /tmp.
  • On Windows, it uses GetTempPath, returning the first non-empty value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory.
  • On Plan 9, it returns /tmp.