Tahinli/forge
public0 watching
★ 0
| 1 | //! Blob storage for release assets. A thin wrapper over object_store's local filesystem backend, |
| 2 | //! so an S3 backend can replace it later without touching the pages. |
| 3 | //! |
| 4 | //! Keys are `assets/<asset id>`. Writes stream through object_store's multipart upload, which |
| 5 | //! assembles the object in a temporary file and renames it into place on `finish`. Every chunk |
| 6 | //! is hashed as it passes, so the sha256 is known without a second read. Blobs are immutable: |
| 7 | //! an asset is never rewritten, only added or deleted. |
| 8 | |
| 9 | use Path; |
| 10 | use Arc; |
| 11 | |
| 12 | use Bytes; |
| 13 | use ; |
| 14 | use ; |
| 15 | use LocalFileSystem; |
| 16 | use Path as ObjectPath; |
| 17 | use ; |
| 18 | use ; |
| 19 | |
| 20 | /// Bytes buffered per upload part before it is handed to the store. |
| 21 | const PART_BYTES: usize = 8 * 1024 * 1024; |
| 22 | /// Parts uploaded at once while a stream is being written. |
| 23 | const PARTS_IN_FLIGHT: usize = 4; |
| 24 | |
| 25 | /// The object key of a release asset. |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | /// The blob store rooted at `<data_dir>/blobs`. Cheap to clone. |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | /// A blob opened for reading: its size and its bytes. |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | /// An upload in progress. Dropping it without `finish` leaves no object behind only if `abort` |
| 105 | /// is called, so every error path in the caller must call `abort`. |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 |