gitlab.com/SkynetLabs/skyd@v1.6.9/skymodules/renter/filesystem/siadir/README.md (about) 1 # SiaDir 2 The SiaDir module is responsible for creating and maintaining the directory 3 metadata information stored in the `.siadir` files on disk. This includes all 4 disk interaction and metadata definition. These siadirs represent directories on 5 the Sia network. 6 7 ## Structure of the SiaDir 8 The SiaDir is a dir on the Sia network and the siadir metadata is a JSON 9 formatted metadata file that contains aggregate and non-aggregate fields. The 10 aggregate fields are the totals of the siadir and any sub siadirs, or are 11 calculated based on all the values in the subtree. The non-aggregate fields are 12 information specific to the siadir that is not an aggregate of the entire sub 13 directory tree 14 15 ## Subsystems 16 The following subsystems help the SiaDir module execute its responsibilities: 17 - [Persistence Subsystem](#persistence-subsystem) 18 - [File Format Subsystem](#file-format-subsystem) 19 - [SiaDirSet Subsystem](#siadirset-subsystem) 20 - [DirReader Subsystem](#dirreader-subsystem) 21 22 ### Persistence Subsystem 23 **Key Files** 24 - [persist.go](./persist.go) 25 26 The Persistence subsystem is responsible for the disk interaction with the 27 `.siadir` files. All the information stored in the `.siadir` file is metadata 28 that can be recalculated on the fly. Because of this, the persistence is not 29 ACID. The persistence relies on a checksum at the beginning of the file to know 30 whether or not the file is corrupt. 31 32 **Exports** 33 - `New` 34 - `LoadSiaDir` 35 - `UpdateMetadata` 36 37 **Inbound Complexities** 38 - `callDelete` deletes a SiaDir from disk 39 - `SiaDirSet.Delete` uses `callDelete` 40 - `LoadSiaDir` loads a SiaDir from disk 41 - `SiaDirSet.open` uses `LoadSiaDir` 42 43 ### File Format Subsystem 44 **Key Files** 45 - [siadir.go](./siadir.go) 46 47 The file format subsystem contains the type definitions for the SiaDir 48 format and methods that return information about the SiaDir. 49 50 **Exports** 51 - `Deleted` 52 - `Metatdata` 53 - `SiaPath` 54 55 ### SiaDirSet Subsystem 56 **Key Files** 57 - [siadirset.go](./siadirset.go) 58 59 A SiaDir object is threadsafe by itself, and to ensure that when a SiaDir is 60 accessed by multiple threads that it is still threadsafe, SiaDirs should always 61 be accessed through the SiaDirSet. The SiaDirSet was created as a pool of 62 SiaDirs which is used by other packages to get access to SiaDirEntries which are 63 wrappers for SiaDirs containing some extra information about how many threads 64 are using it at a certain time. If a SiaDir was already loaded the SiaDirSet 65 will hand out the existing object, otherwise it will try to load it from disk. 66 67 **Exports** 68 - `HealthPercentage` 69 - `NewSiaDirSet` 70 - `Close` 71 - `Delete` 72 - `DirInfo` 73 - `DirList` 74 - `Exists` 75 - `InitRootDir` 76 - `NewSiaDir` 77 - `Open` 78 - `Rename` 79 80 **Outbound Complexities** 81 - `Delete` will use `callDelete` to delete the SiaDir once it has been acquired 82 in the set 83 - `open` calls `LoadSiaDir` to load the SiaDir from disk 84 85 ### DirReader Subsystem 86 **Key Files** 87 - [dirreader.go](./dirreader.go) 88 89 The DirReader Subsystem creates the DirReader which is used as a helper to read 90 raw .siadir from disk 91 92 **Exports** 93 - `Close` 94 - `Read` 95 - `Stat` 96 - `DirReader`