lbryio / lbry-sdk

The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
https://lbry.com
MIT License
7.19k stars 482 forks source link

Detect non-writable and full data directories #3420

Closed pseudoscalar closed 2 years ago

pseudoscalar commented 3 years ago

To resolve 3270

coveralls commented 3 years ago

Coverage Status

Coverage decreased (-0.09%) to 67.963% when pulling ebb142b6f794e3a1c785e338105ba7dd2c87bb7c on pseudoscalar:issue/3270 into 358ef4536feb43e910f515d7993d92fe7012cd0c on lbryio:master.

pseudoscalar commented 3 years ago

I've made the requested changes. Was there anything else you wanted me to do to this?

eukreign commented 3 years ago

@lyoshenka this PR writes three 1MB files in three directories (then deletes them) as part of startup to determine if "disk is full when sdk starts" (per bonus feature in #3270), is this what you had in mind?

lyoshenka commented 3 years ago

That works, though I'm surprised that's necessary. What if the sdk crashes after writing the file and before deleting it? What if we run several SDKs in parallel (say, in a test)?

To check for write permissions, I assumed you'd just need to check whether the directories are writable by the user/group of the SDK process. For whether the disk is full, you can check if the partition containing the directories has space.