tobychui / SlicerA

A web based STL to Gcode slicer for ArozOS
Apache License 2.0
25 stars 5 forks source link

use system tmp folder #2

Closed aligator closed 3 years ago

aligator commented 3 years ago

Hi,

as I am not sure what you think about it I wanted to discuss this before creating a PR:

I would suggest to use ioutil.TempFile https://gobyexample.com/temporary-files-and-directories as it's the preferred way to create tmp files in Go.

What do you think?

tobychui commented 3 years ago

Hi @aligator, I think keeping the existing method of tmp folder allocation is a better decision then using the Golang build-in one. Here are twp points that I think are important.

  1. ArozOS and SlicerA are both designed to be usable on low power ARM based single board computers (SBCs). Some of the SBCs have as little as 512MB RAM which makes the /tmp folder not have enough space to buffer a large STL file. ( I have used the ioutil.TempFile method in ArozOS on those SBC before and this was what I concluded as the best approach to buffer a large file in these type of embedded systems)
  2. Future updates might allow us to set the tmp folder location with startup flags to different drives (e.g. if you are deploying on cloud VM for example) if we keep the current implementation.

In summary, I will be suggesting that we can keep this part first and in future updates, we can allow user to define their own tmp folder location if needed. Do you think this will be a better approach?

aligator commented 3 years ago

Ah ok, I see. The only thing I can think of would be to just use the ioutil.TempFile in the standalone mode only. But yes, for now it's ok. Maybe we just leave this ticket open until we know how to handle it better?

tobychui commented 3 years ago

I have added the custom flags for allowing user defined tmp folder. To use it, start SlicerA with the -tmp flag. Here is an example,

./SlicerA -tmp "/tmp"

Then all tmp files will be buffered to the system /tmp folder (which is the same as the place where ioutil buffers its temp files). Or otherwise, leave it as default for generating as the SlicerA's root folder.

I guess this is good enough for now. Let me know if you have other thought and I will re-open the issue if needed. Thanks!