Proposal: Add a readonly SiaFile type for readonly operations like downloading/streaming
I've been thinking about doing backups/snapshots, locking and the SiaFile format overall and it seems like we need to figure out how to allow uploads to add new chunks to a file and to change chunks while other threads potentially download the same file.
I think a good way to do that is to add a Clone
/Snapshot
method to the SiaFile
which creates a deep copy of the SiaFile in memory and only allows calling methods on the file which don't change it. Then instead of using a SiaFile
, the download loop would simply create a snapshot when the download is initiated and use that instead.
This also reduces the amount of locking for readonly operation to a single mu.Lock
and mu.Unlock
when creating the copy.