NebulousLabs / Sia

Blockchain-based marketplace for file storage. Project has moved to GitLab: https://gitlab.com/NebulousLabs/Sia
https://sia.tech
MIT License
2.71k stars 440 forks source link

Siac Absolute Filepath #3144

Open DavidVorick opened 6 years ago

DavidVorick commented 6 years ago

Siac has an abs(dir string) function which converts a relative path into an absolute path. First, this is a bad name for a function that operates widely in a package, we should change the name of the function to be absolutePath(dir string)

Second, the abs function does not gracefully handle being run in a directory that does not exist. A terminal can end up in a directory that doesn't exist if another program deletes the directory while the terminal is cd'd into that directory. We need to clean up the abs function so that it gracefully handles being in a non-existent directory.

ChrisSchinnerl commented 6 years ago

Could you clarify what you mean by "gracefully handle"? I think the code that uses the path should handle the invalid path because there is no guarantee that just because the path existed while calling abs(...) it will continue to exist until actually using the path.