mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
528240026d
- make format 现在与 code-check 使用同一格式化器(golangci-lint fmt),消除 goimports -local 与 gofumpt 的格式拉锯 - .golangci.yml 关闭默认 50/3 截断,完整上报所有问题(只增强不弱化) - 全库 gofumpt 规范化(203 files, 纯格式无行为变更)
33 lines
902 B
Go
33 lines
902 B
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package storage
|
|
|
|
import (
|
|
"Wavelet/core/contracts"
|
|
"Wavelet/pkg/logger"
|
|
"Wavelet/plugins/domain/upload/models"
|
|
"Wavelet/plugins/domain/upload/shared"
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// ReadOnly checks if the storage system is in read-only maintenance mode.
|
|
func ReadOnly(ctx context.Context) bool {
|
|
state := LoadMigrationAccessState(ctx)
|
|
if state.LoadErr != nil {
|
|
logger.ErrorF(ctx, "读取存储维护状态失败: %v", state.LoadErr)
|
|
return true
|
|
}
|
|
return state.ReadOnly
|
|
}
|
|
|
|
// OpenStoredObject opens a stored upload object from the active storage backend.
|
|
func OpenStoredObject(ctx context.Context, upload *models.Upload) (*contracts.StorageObject, error) {
|
|
storageSvc := shared.GetStorage(ctx)
|
|
if storageSvc == nil {
|
|
return nil, errors.New("storage service not available")
|
|
}
|
|
return storageSvc.Get(ctx, upload.FilePath)
|
|
}
|