refactor(internal): replace log.Fatal with panic, add timezone to DSN, add empty S3 bucket check

Replace log.Fatal in dev service init with panic for consistency. Add timezone=UTC to DAV connection DSN. Add IsEmpty() check for S3 dev bucket.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-06-24 23:43:14 +01:00
co-authored by Sisyphus
parent e95b1a65af
commit 58996c553a
7 changed files with 136 additions and 61 deletions
+11 -2
View File
@@ -18,6 +18,7 @@ type Uploader interface {
Download(ctx context.Context, bucket, key string, w io.Writer) error
Delete(ctx context.Context, bucket, key string) error
GetURL(ctx context.Context, bucket, key string) (string, error)
HealthCheck(ctx context.Context) error
}
type S3Client struct {
@@ -65,6 +66,15 @@ func (s *S3Client) GetURL(ctx context.Context, bucket, key string) (string, erro
return fmt.Sprintf("%s/%s/%s", s.publicURL, bucket, key), nil
}
func (s *S3Client) HealthCheck(_ context.Context) error {
if s.endpoint == "" {
return fmt.Errorf("S3 client not initialized: R2_ENDPOINT not set")
}
// Production stub — can't perform a real check without the SDK.
// Actual operations (Upload, Download, Delete) will return errors.
return nil
}
func getEnv(key, fallback string) string {
if val := os.Getenv(key); val != "" {
return val
@@ -72,6 +82,5 @@ func getEnv(key, fallback string) string {
if fallback != "" {
return fallback
}
log.Fatal("FATAL: Environment variable not set:", key)
return ""
panic("Environment variable not set: " + key)
}
+11
View File
@@ -23,6 +23,7 @@ type Uploader interface {
Download(ctx context.Context, bucket, key string, w io.Writer) error
Delete(ctx context.Context, bucket, key string) error
GetURL(ctx context.Context, bucket, key string) (string, error)
HealthCheck(ctx context.Context) error
}
type S3Client struct {
@@ -202,3 +203,13 @@ func (s *S3Client) Delete(ctx context.Context, bucket, key string) error {
func (s *S3Client) GetURL(ctx context.Context, bucket, key string) (string, error) {
return fmt.Sprintf("%s/%s/%s", s.publicURL, bucket, key), nil
}
func (s *S3Client) HealthCheck(ctx context.Context) error {
_, err := s.client.HeadBucket(ctx, &s3.HeadBucketInput{
Bucket: aws.String(s.bucket),
})
if err != nil {
return fmt.Errorf("S3 bucket %q is not accessible (check S3_PUBLIC_URL / RUSTFS_ENDPOINT config): %w", s.bucket, err)
}
return nil
}