Commit c0208b3
Eric Bower
·
2026-03-28 21:28:51 -0400 EDT
parent d51ab87
chore(storage): cleanup
6 files changed,
+18,
-15
+1,
-1
| ... | ... | @@ -48,7 +48,7 @@ type Cmd struct { | |
| 48 | 48 | User *db.User | |
| 49 | 49 | Session shared.CmdSession | |
| 50 | 50 | Log *slog.Logger | |
| 51 | - | Store storage.ObjectStorage | |
| 51 | + | Store storage.StorageServe | |
| 52 | 52 | Dbpool pgsdb.PgsDB | |
| 53 | 53 | Write bool | |
| 54 | 54 | Width int |
+1,
-1
| ... | ... | @@ -92,7 +92,7 @@ func toDisplayEntries(entries []os.FileInfo) []dirEntryDisplay { | |
| 92 | 92 | return displayEntries | |
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | - | func shouldGenerateListing(st storage.ObjectStorage, bucket storage.Bucket, projectDir string, path string) bool { | |
| 95 | + | func shouldGenerateListing(st storage.StorageServe, bucket storage.Bucket, projectDir string, path string) bool { | |
| 96 | 96 | dirPath := projectDir + path | |
| 97 | 97 | if path == "/" { | |
| 98 | 98 | dirPath = projectDir + "/" |
+2,
-2
| ... | ... | @@ -43,8 +43,8 @@ type StorageFS struct { | |
| 43 | 43 | Logger *slog.Logger | |
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | - | var _ ObjectStorage = &StorageFS{} | |
| 47 | - | var _ ObjectStorage = (*StorageFS)(nil) | |
| 46 | + | var _ StorageServe = &StorageFS{} | |
| 47 | + | var _ StorageServe = (*StorageFS)(nil) | |
| 48 | 48 | ||
| 49 | 49 | func NewStorageFS(logger *slog.Logger, dir string) (*StorageFS, error) { | |
| 50 | 50 | return &StorageFS{Logger: logger, Dir: dir}, nil |
+1,
-1
| ... | ... | @@ -39,7 +39,7 @@ type FileData struct { | |
| 39 | 39 | ||
| 40 | 40 | type Config struct { | |
| 41 | 41 | Logger *slog.Logger | |
| 42 | - | Storage ObjectStorage | |
| 42 | + | Storage StorageServe | |
| 43 | 43 | AssetNames AssetNames | |
| 44 | 44 | } | |
| 45 | 45 |
+2,
-2
| ... | ... | @@ -19,8 +19,8 @@ type StorageMemory struct { | |
| 19 | 19 | mu sync.RWMutex | |
| 20 | 20 | } | |
| 21 | 21 | ||
| 22 | - | var _ ObjectStorage = &StorageMemory{} | |
| 23 | - | var _ ObjectStorage = (*StorageMemory)(nil) | |
| 22 | + | var _ StorageServe = &StorageMemory{} | |
| 23 | + | var _ StorageServe = (*StorageMemory)(nil) | |
| 24 | 24 | ||
| 25 | 25 | func NewStorageMemory(st map[string]map[string]string) (*StorageMemory, error) { | |
| 26 | 26 | return &StorageMemory{ |
+11,
-8
| ... | ... | @@ -15,27 +15,30 @@ type Bucket struct { | |
| 15 | 15 | Root string | |
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | - | type ObjectStorage interface { | |
| 18 | + | type ObjectInfo struct { | |
| 19 | + | Size int64 | |
| 20 | + | LastModified time.Time | |
| 21 | + | ETag string | |
| 22 | + | Metadata http.Header | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | type BucketStorage interface { | |
| 19 | 26 | GetBucket(name string) (Bucket, error) | |
| 20 | 27 | GetBucketQuota(bucket Bucket) (uint64, error) | |
| 21 | 28 | UpsertBucket(name string) (Bucket, error) | |
| 22 | 29 | ListBuckets() ([]string, error) | |
| 23 | 30 | DeleteBucket(bucket Bucket) error | |
| 31 | + | } | |
| 24 | 32 | ||
| 33 | + | type ObjectStorage interface { | |
| 25 | 34 | GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderAtCloser, *ObjectInfo, error) | |
| 26 | 35 | PutObject(bucket Bucket, fpath string, contents io.Reader, entry *utils.FileEntry) (string, int64, error) | |
| 27 | 36 | DeleteObject(bucket Bucket, fpath string) error | |
| 28 | 37 | ListObjects(bucket Bucket, dir string, recursive bool) ([]os.FileInfo, error) | |
| 29 | 38 | } | |
| 30 | 39 | ||
| 31 | - | type ObjectInfo struct { | |
| 32 | - | Size int64 | |
| 33 | - | LastModified time.Time | |
| 34 | - | ETag string | |
| 35 | - | Metadata http.Header | |
| 36 | - | } | |
| 37 | - | ||
| 38 | 40 | type StorageServe interface { | |
| 41 | + | BucketStorage | |
| 39 | 42 | ObjectStorage | |
| 40 | 43 | ServeObject(r *http.Request, bucket Bucket, fpath string, opts *ImgProcessOpts) (io.ReadCloser, *ObjectInfo, error) | |
| 41 | 44 | } |